解决HGSaneUser库在linux上的编译问题
This commit is contained in:
parent
80a407939f
commit
44a16deae0
|
@ -71,7 +71,7 @@ DeviceUserMgr::DeviceUserMgr(QWidget *wnd)
|
||||||
{
|
{
|
||||||
m_wnd = wnd;
|
m_wnd = wnd;
|
||||||
m_saneMgr = nullptr;
|
m_saneMgr = nullptr;
|
||||||
HGSane_CreateManager("sane.dll", &m_saneMgr);
|
HGSane_CreateManager(&m_saneMgr);
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceUserMgr::~DeviceUserMgr()
|
DeviceUserMgr::~DeviceUserMgr()
|
||||||
|
@ -82,20 +82,26 @@ DeviceUserMgr::~DeviceUserMgr()
|
||||||
|
|
||||||
class DeviceUser* DeviceUserMgr::OpenDeviceUser()
|
class DeviceUser* DeviceUserMgr::OpenDeviceUser()
|
||||||
{
|
{
|
||||||
HGSaneDevice dev = nullptr;
|
HGSaneSource source = nullptr;
|
||||||
#ifdef HG_CMP_MSC
|
HGSane_OpenSelectedSource(m_saneMgr, m_wnd, &source);
|
||||||
HGSane_OpenSelectedDevice(m_saneMgr, (HWND)m_wnd->winId(), &dev);
|
if (nullptr == source)
|
||||||
#else
|
|
||||||
HGSane_OpenSelectedDevice(m_saneMgr, m_wnd, &dev);
|
|
||||||
#endif
|
|
||||||
if (nullptr == dev)
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return new DeviceUser(m_wnd, dev);
|
|
||||||
|
HGSaneDevice dev = nullptr;
|
||||||
|
HGSane_OpenSelectedDevice(source, m_wnd, &dev);
|
||||||
|
if (nullptr == dev)
|
||||||
|
{
|
||||||
|
HGSane_CloseSource(source);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new DeviceUser(m_wnd, source, dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceUser::DeviceUser(QWidget *wnd, HGSaneDevice dev)
|
DeviceUser::DeviceUser(QWidget *wnd, HGSaneSource source, HGSaneDevice dev)
|
||||||
{
|
{
|
||||||
m_wnd = wnd;
|
m_wnd = wnd;
|
||||||
|
m_source = source;
|
||||||
m_saneDev = dev;
|
m_saneDev = dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,6 +109,8 @@ DeviceUser::~DeviceUser()
|
||||||
{
|
{
|
||||||
HGSane_CloseDevice(m_saneDev);
|
HGSane_CloseDevice(m_saneDev);
|
||||||
m_saneDev = nullptr;
|
m_saneDev = nullptr;
|
||||||
|
HGSane_CloseSource(m_source);
|
||||||
|
m_source = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DeviceUser::GetName()
|
QString DeviceUser::GetName()
|
||||||
|
@ -114,20 +122,12 @@ QString DeviceUser::GetName()
|
||||||
|
|
||||||
HGResult DeviceUser::ShowSettingDlg()
|
HGResult DeviceUser::ShowSettingDlg()
|
||||||
{
|
{
|
||||||
#ifdef HG_CMP_MSC
|
|
||||||
return HGSane_ShowDeviceSettingDlg(m_saneDev, (HWND)m_wnd->winId());
|
|
||||||
#else
|
|
||||||
return HGSane_ShowDeviceSettingDlg(m_saneDev, m_wnd);
|
return HGSane_ShowDeviceSettingDlg(m_saneDev, m_wnd);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HGResult DeviceUser::StartScan()
|
HGResult DeviceUser::StartScan()
|
||||||
{
|
{
|
||||||
#ifdef HG_CMP_MSC
|
|
||||||
return HGSane_StartDeviceWithUI(m_saneDev, (HWND)m_wnd->winId(), DeviceImageFunc, this);
|
|
||||||
#else
|
|
||||||
return HGSane_StartDeviceWithUI(m_saneDev, m_wnd, DeviceImageFunc, this);
|
return HGSane_StartDeviceWithUI(m_saneDev, m_wnd, DeviceImageFunc, this);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HGAPI DeviceUser::DeviceImageFunc(HGSaneDevice dev, HGImage image, HGPointer param)
|
void HGAPI DeviceUser::DeviceImageFunc(HGSaneDevice dev, HGImage image, HGPointer param)
|
||||||
|
|
|
@ -75,7 +75,7 @@ class DeviceUser : public QObject
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
friend class DeviceUserMgr;
|
friend class DeviceUserMgr;
|
||||||
DeviceUser(QWidget *wnd, HGSaneDevice dev);
|
DeviceUser(QWidget *wnd, HGSaneSource source, HGSaneDevice dev);
|
||||||
public:
|
public:
|
||||||
~DeviceUser();
|
~DeviceUser();
|
||||||
|
|
||||||
|
@ -94,6 +94,7 @@ signals:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget *m_wnd;
|
QWidget *m_wnd;
|
||||||
|
HGSaneSource m_source;
|
||||||
HGSaneDevice m_saneDev;
|
HGSaneDevice m_saneDev;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,8 @@ HGResult HGSaneManagerImpl::OpenSelectedSource(HGWindow parent, class HGSaneSour
|
||||||
f_sane_init fInit = NULL;
|
f_sane_init fInit = NULL;
|
||||||
f_sane_exit fExit = NULL;
|
f_sane_exit fExit = NULL;
|
||||||
SANEAPI saneAPI;
|
SANEAPI saneAPI;
|
||||||
if (-2 == show_srclist_ui(parent, &dll, &fInit, &fExit, &saneAPI))
|
char manuName[256];
|
||||||
|
if (-2 == show_srclist_ui(parent, &dll, &fInit, &fExit, &saneAPI, manuName, 256))
|
||||||
{
|
{
|
||||||
return HGBASE_ERR_NOTSUPPORT;
|
return HGBASE_ERR_NOTSUPPORT;
|
||||||
}
|
}
|
||||||
|
@ -92,7 +93,7 @@ HGResult HGSaneManagerImpl::OpenSelectedSource(HGWindow parent, class HGSaneSour
|
||||||
}
|
}
|
||||||
|
|
||||||
HGSaneSourceImpl* newSourceImpl = new HGSaneSourceImpl(this);
|
HGSaneSourceImpl* newSourceImpl = new HGSaneSourceImpl(this);
|
||||||
HGResult ret = newSourceImpl->Init(dll, fInit, fExit, &saneAPI);
|
HGResult ret = newSourceImpl->Init(manuName, dll, fInit, fExit, &saneAPI);
|
||||||
if (HGBASE_ERR_OK != ret)
|
if (HGBASE_ERR_OK != ret)
|
||||||
{
|
{
|
||||||
delete newSourceImpl;
|
delete newSourceImpl;
|
||||||
|
|
|
@ -13,7 +13,8 @@ extern HINSTANCE g_hInst;
|
||||||
extern bool g_ownApplication;
|
extern bool g_ownApplication;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int show_srclist_ui(HGWindow parent, HGDll *dll, f_sane_init *fInit, f_sane_exit *fExit, SANEAPI* saneApi)
|
int show_srclist_ui(HGWindow parent, HGDll *dll, f_sane_init *fInit, f_sane_exit *fExit,
|
||||||
|
SANEAPI* saneApi, char *manuName, unsigned int maxLen)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,8 @@ typedef SANE_Status (*f_sane_init)(SANE_Int* version_code, SANE_Auth_Callback au
|
||||||
typedef void (*f_sane_exit)(void);
|
typedef void (*f_sane_exit)(void);
|
||||||
typedef void (*show_scan_ui_image_callback)(const SANE_Parameters *imageFormat, const SANE_Byte *imageData, void * callbackParam);
|
typedef void (*show_scan_ui_image_callback)(const SANE_Parameters *imageFormat, const SANE_Byte *imageData, void * callbackParam);
|
||||||
|
|
||||||
HGEXPORT int show_srclist_ui(HGWindow parent, HGDll *dll, f_sane_init *fInit, f_sane_exit *fExit, SANEAPI* saneApi);
|
HGEXPORT int show_srclist_ui(HGWindow parent, HGDll *dll, f_sane_init *fInit, f_sane_exit *fExit,
|
||||||
|
SANEAPI* saneApi, char *manuName, unsigned int maxLen);
|
||||||
HGEXPORT int show_devlist_ui(const SANEAPI* saneApi, HGWindow parent, SANE_Handle *handle, char *devName, unsigned int maxLen);
|
HGEXPORT int show_devlist_ui(const SANEAPI* saneApi, HGWindow parent, SANE_Handle *handle, char *devName, unsigned int maxLen);
|
||||||
HGEXPORT int show_setting_ui(const SANEAPI* saneApi, SANE_Handle handle, const char *devName, HGWindow parent);
|
HGEXPORT int show_setting_ui(const SANEAPI* saneApi, SANE_Handle handle, const char *devName, HGWindow parent);
|
||||||
HGEXPORT int show_scan_ui(const SANEAPI* saneApi, SANE_Handle handle, const char *devName, HGWindow parent,
|
HGEXPORT int show_scan_ui(const SANEAPI* saneApi, SANE_Handle handle, const char *devName, HGWindow parent,
|
||||||
|
|
Loading…
Reference in New Issue