Changeset 1058 for trunk/src/gui


Ignore:
Timestamp:
Sep 7, 2011, 1:09:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

OS/2: Enable linking to cups.dll at runtime.

This requires CUPS 1.4.8 and above. Older versions will not
work anymore.

Location:
trunk/src/gui/painting
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gui/painting/qcups.cpp

    r846 r1058  
    5050
    5151QT_BEGIN_NAMESPACE
    52 
    53 #ifndef Q_WS_PM
    5452
    5553typedef int (*CupsGetDests)(cups_dest_t **dests);
     
    8886static CupsPrintFile _cupsPrintFile = 0;
    8987
    90 #else // ifndef Q_WS_PM
    91 
    92 // On OS/2, we link to libcups statically
    93 
    94 static bool cupsLoaded = false;
    95 static int qt_cups_num_printers = 0;
    96 
    97 #define _cupsGetDests cupsGetDests
    98 #define _cupsFreeDests cupsFreeDests
    99 #define _cupsGetPPD cupsGetPPD
    100 #define _cupsLangGet cupsLangGet
    101 #define _cupsLangEncoding cupsLangEncoding
    102 #define _ppdOpenFile ppdOpenFile
    103 #define _ppdMarkDefaults ppdMarkDefaults
    104 #define _ppdClose ppdClose
    105 #define _cupsMarkOptions cupsMarkOptions
    106 #define _ppdMarkOption ppdMarkOption
    107 #define _cupsFreeOptions cupsFreeOptions
    108 #define _cupsSetDests cupsSetDests
    109 #define _cupsAddOption cupsAddOption
    110 #define _cupsTempFd cupsTempFd
    111 #define _cupsPrintFile cupsPrintFile
    112 
    113 #endif // ifndef Q_WS_PM
     88#ifdef Q_OS_OS2
     89#define CUPS_RESOLVE_cups(func) _cups##func = (Cups##func) cupsLib.resolve("_cups"#func)
     90#define CUPS_RESOLVE_ppd(func) _ppd##func = (PPD##func) cupsLib.resolve("_ppd"#func)
     91#else
     92#define CUPS_RESOLVE_cups(func) _cups##func = (Cups##func) cupsLib.resolve("cups"#func)
     93#define CUPS_RESOLVE_ppd(func) _ppd##func = (PPD##func) cupsLib.resolve("ppd"#func)
     94#endif
    11495
    11596static void resolveCups()
    11697{
    117 #ifndef Q_WS_PM
    11898    QLibrary cupsLib(QLatin1String("cups"), 2);
    11999    if(cupsLib.load()) {
    120         _cupsGetDests = (CupsGetDests) cupsLib.resolve("cupsGetDests");
    121         _cupsFreeDests = (CupsFreeDests) cupsLib.resolve("cupsFreeDests");
    122         _cupsGetPPD = (CupsGetPPD) cupsLib.resolve("cupsGetPPD");
    123         _cupsLangGet = (CupsLangGet) cupsLib.resolve("cupsLangGet");
    124         _cupsLangEncoding = (CupsLangEncoding) cupsLib.resolve("cupsLangEncoding");
    125         _ppdOpenFile = (PPDOpenFile) cupsLib.resolve("ppdOpenFile");
    126         _ppdMarkDefaults = (PPDMarkDefaults) cupsLib.resolve("ppdMarkDefaults");
    127         _ppdClose = (PPDClose) cupsLib.resolve("ppdClose");
    128         _cupsMarkOptions = (CupsMarkOptions) cupsLib.resolve("cupsMarkOptions");
    129         _ppdMarkOption = (PPDMarkOption) cupsLib.resolve("ppdMarkOption");
    130         _cupsFreeOptions = (CupsFreeOptions) cupsLib.resolve("cupsFreeOptions");
    131         _cupsSetDests = (CupsSetDests) cupsLib.resolve("cupsSetDests");
    132         _cupsAddOption = (CupsAddOption) cupsLib.resolve("cupsAddOption");
    133         _cupsTempFd = (CupsTempFd) cupsLib.resolve("cupsTempFd");
    134         _cupsPrintFile = (CupsPrintFile) cupsLib.resolve("cupsPrintFile");
     100        CUPS_RESOLVE_cups(GetDests);
     101        CUPS_RESOLVE_cups(FreeDests);
     102        CUPS_RESOLVE_cups(GetPPD);
     103        CUPS_RESOLVE_cups(LangGet);
     104        CUPS_RESOLVE_cups(LangEncoding);
     105        CUPS_RESOLVE_ppd(OpenFile);
     106        CUPS_RESOLVE_ppd(MarkDefaults);
     107        CUPS_RESOLVE_ppd(Close);
     108        CUPS_RESOLVE_cups(MarkOptions);
     109        CUPS_RESOLVE_ppd(MarkOption);
     110        CUPS_RESOLVE_cups(FreeOptions);
     111        CUPS_RESOLVE_cups(SetDests);
     112        CUPS_RESOLVE_cups(AddOption);
     113        CUPS_RESOLVE_cups(TempFd);
     114        CUPS_RESOLVE_cups(PrintFile);
    135115
    136116        if (_cupsGetDests && _cupsFreeDests) {
    137 #endif
    138117            cups_dest_t *printers;
    139118            int num_printers = _cupsGetDests(&printers);
     
    141120                _cupsFreeDests(num_printers, printers);
    142121            qt_cups_num_printers = num_printers;
    143 #ifndef Q_WS_PM
    144         }
    145     }
    146 #endif
     122        }
     123    }
    147124    cupsLoaded = true;
    148125}
     
    250227
    251228    return
    252 #ifndef Q_WS_PM
    253229        _cupsGetDests &&
    254230        _cupsFreeDests &&
     
    264240        _cupsLangEncoding &&
    265241        _cupsAddOption &&
    266 #endif
    267242        (qt_cups_num_printers > 0);
    268243}
  • trunk/src/gui/painting/qcups_p.h

    r846 r1058  
    6060#ifndef QT_NO_CUPS
    6161
    62 #ifndef Q_WS_PM
    6362#include <QtCore/qlibrary.h>
    64 #endif
    6563#include <cups/cups.h>
    6664#include <cups/ppd.h>
Note: See TracChangeset for help on using the changeset viewer.