Twain_DSM  1.0
Modules | Classes | Macros | Enumerations | Enumerator | Functions | Variables

We want to use secure string functions whenever possible, if g++ every includes a set I think it would be excellent to switch over to it, but at least with Windows using them we stand a better chance of finding boo-boos... More...

Collaboration diagram for use secure string functions if we have them:

Modules

 logging defines and functions
 These functions are insecure, but everybody has them, so we don't need an else/error section like we use everywhere else...
 

Classes

class  CTwnDsmLog
 Our logging class. More...
 
class  CTwnDsmApps
 Class to hold list of connected applications. More...
 
class  CTwnDsm
 This is the main class for the Data Source Manager. More...
 
struct  CTwnDsm::_pod
 We use a pod system because it help prevents us from making dumb initialization mistakes. More...
 

Macros

#define SSTRCPY(d, z, s)   strncpy_s(d,z,s,_TRUNCATE)
 Secure String copy. More...
 
#define SSTRCAT(d, z, s)   strncat_s(d,z,s,_TRUNCATE)
 Secure String catinate. More...
 
#define SSTRNCPY(d, z, s, m)   strncpy_s(d,z,s,m)
 Secure String n copy. More...
 
#define SGETENV(d, z, n)   ::GetEnvironmentVariable(n,d,z)
 Secure Get enviroment varable. More...
 
#define kLOGINFO   0,__FILE__,__LINE__
 write info messages to LogFile.
 
#define kLOGERR   1,__FILE__,__LINE__
 write error messages to LogFile.
 
#define kLOG(a)   if (g_ptwndsmlog) g_ptwndsmlog->Log a
 Define to write messages to LogFile. More...
 
#define kPANIC(msg)   ::MessageBox(NULL,msg,"TWAIN Data Source Manager",MB_OK);
 Display message to user. More...
 
#define MAX_NUM_DS   50
 Maximum number of Data Sources that can be opened under one application. More...
 

Enumerations

enum  DSM_State { dsmState_PreSession = 1, dsmState_Loaded = 2, dsmState_Open = 3 }
 Possible States of the DSM. More...
 

Functions

int SSNPRINTF (char *d, const size_t z, const size_t c, const char *const f,...)
 
void * DSM_LoadFunction (void *_pHandle, const char *_pszSymbol)
 This function wraps the function loading calls. More...
 
 CTwnDsmLog::CTwnDsmLog ()
 The CTwnDsmLog constructor. More...
 
 CTwnDsmLog::~CTwnDsmLog ()
 The CTwnDsmLog destructor. More...
 
void CTwnDsmLog::Log (const int _doassert, const char *const _file, const int _line, const char *const _format,...)
 The logging function. More...
 
void CTwnDsmLog::Indent (int nChange)
 Indent the logging to help with seeing recursive calls param[in] nChange Either +1 or -1.
 
 CTwnDsmApps::CTwnDsmApps ()
 The CTwnDsmApps constructor. More...
 
 CTwnDsmApps::~CTwnDsmApps ()
 The CTwnDsmApps destructor. More...
 
TW_UINT16 CTwnDsmApps::AddApp (TW_IDENTITY *_pAppId, TW_MEMREF _MemRef)
 Add an application. More...
 
TW_UINT16 CTwnDsmApps::RemoveApp (TW_IDENTITY *_pAppId)
 Remove an application. More...
 
TW_INT16 CTwnDsmApps::LoadDS (TW_IDENTITY *_pAppId, TWID_T _DsId)
 Loads a DS from disk and adds it to a global list of DS's. More...
 
void CTwnDsmApps::UnloadDS (TW_IDENTITY *_pAppId, TWID_T _DsId)
 Unloads a DS and frees all its resources... More...
 
TW_BOOL CTwnDsmApps::AppValidateId (TW_IDENTITY *_pAppId)
 Validate that an id is in range... More...
 
TW_BOOL CTwnDsmApps::AppValidateIds (TW_IDENTITY *_pAppId, TW_IDENTITY *_pDSId)
 Validate that the App ID and DS ID are in range... More...
 
TW_IDENTITYCTwnDsmApps::AppGetIdentity (TW_IDENTITY *_pAppId)
 Return a pointer to the application's identity. More...
 
TW_UINT16 CTwnDsmApps::AppGetConditionCode (TW_IDENTITY *_pAppId)
 Get the condition code, then reset it internally to TWCC_SUCCESS, so you can only get it once, per the specification... More...
 
void CTwnDsmApps::AppSetConditionCode (TW_IDENTITY *_pAppId, TW_UINT16 _conditioncode)
 Set the condition code. More...
 
DSM_State CTwnDsmApps::AppGetState ()
 Get the state of the DSM for all applications. More...
 
DSM_State CTwnDsmApps::AppGetState (TW_IDENTITY *_pAppId)
 Get the state of the DSM for the specified application. More...
 
void * CTwnDsmApps::AppHwnd (TW_IDENTITY *_pAppId)
 Get the hwnd sent in with the call to MSG_OPENDSM. More...
 
TWID_T CTwnDsmApps::AppGetNumDs (TW_IDENTITY *_pAppId)
 Get the number of drivers we found as the result of a successful call to LoadDS with _boolKeepOpen set to false (meaning that we were just browsing)... More...
 
void CTwnDsmApps::AppWakeup (TW_IDENTITY *_pAppId)
 Poke the application to wake it up when sending a DAT_NULL message to it... More...
 
TW_IDENTITYCTwnDsmApps::DsGetIdentity (TW_IDENTITY *_pAppId, TWID_T _DsId)
 Get a pointer to the identity of the specified driver... More...
 
DSENTRYPROC CTwnDsmApps::DsGetEntryProc (TW_IDENTITY *_pAppId, TWID_T _DsId)
 Get a pointer to the DS_Entry function of the specified driver... More...
 
char * CTwnDsmApps::DsGetPath (TW_IDENTITY *_pAppId, TWID_T _DsId)
 Get a pointer to the driver file path and name, which is guaranteed to be unique, even if the ProductName's aren't for some horrible reason... More...
 
TW_CALLBACK2CTwnDsmApps::DsCallback2Get (TW_IDENTITY *_pAppId, TWID_T _DsId)
 Get a pointer to TW_CALLBACK structure for the specified driver... More...
 
TW_BOOL CTwnDsmApps::DsCallbackIsWaiting (TW_IDENTITY *_pAppId, TWID_T _DsId)
 Test if the driver has a callback pending for attention... More...
 
void CTwnDsmApps::DsCallbackSetWaiting (TW_IDENTITY *_pAppId, TWID_T _DsId, TW_BOOL _Waiting)
 Set the callback flag for the driver to TRUE if the callback needs to have its callback called, and set it to FALSE after the call has been made... More...
 
TW_BOOL CTwnDsmApps::DsIsProcessingMessage (TW_IDENTITY *_pAppId, TWID_T _DsId)
 Check if the DS is still processing last message. More...
 
void CTwnDsmApps::DsSetProcessingMessage (TW_IDENTITY *_pAppId, TWID_T _DsId, TW_BOOL _Processing)
 Set the ProcessingMessage flag. More...
 
TW_BOOL CTwnDsmApps::DsIsAppProcessingCallback (TW_IDENTITY *_pAppId, TWID_T _DsId)
 Check if the App is still processing last callback. More...
 
void CTwnDsmApps::DsSetAppProcessingCallback (TW_IDENTITY *_pAppId, TWID_T _DsId, TW_BOOL _Processing)
 Set the AppProcessingCallback flag. More...
 
TWID_T CTwnDsmApps::AppGetNumApp ()
 Get number of allocated App slots (Last valid App ID +1) More...
 
 CTwnDsm::CTwnDsm ()
 Our CTwnDsm constructor...
 
 CTwnDsm::~CTwnDsm ()
 Our CTwnDsm destructor...
 
TW_UINT16 CTwnDsm::DSM_Entry (TW_IDENTITY *_pOrigin, TW_IDENTITY *_pDest, TW_UINT32 _DG, TW_UINT16 _DAT, TW_UINT16 _MSG, TW_MEMREF _pData)
 The guts of the DSM_Entry, the resource management portion resides in a our DSM_Entry entry point, which isn't a part of this class. More...
 
BOOL CALLBACK CTwnDsm::SelectDlgProc (HWND _hWnd, UINT _Message, WPARAM _wParam, LPARAM _lParam)
 Selection dialog, for apps that don't want to do GetFirst GetNext. More...
 
DSM_State CTwnDsm::DSMGetState ()
 Get the state of the DSM by checking the state of all applications. More...
 
TW_INT16 CTwnDsm::DSM_Null (TW_IDENTITY *_pAppId, TW_IDENTITY *_pDsId, TW_UINT16 _MSG)
 Handles DAT_NULL calls from DS for Application. More...
 
TW_INT16 CTwnDsm::DSM_Status (TW_IDENTITY *_pAppId, TW_UINT16 _MSG, TW_STATUS *_pStatus)
 Returns the current DSM status. More...
 
TW_INT16 CTwnDsm::DSM_Parent (TW_IDENTITY *_pAppId, TW_UINT16 _MSG, TW_MEMREF _MemRef)
 Initializes or closes the DSM. More...
 
TW_INT16 CTwnDsm::DSM_Identity (TW_IDENTITY *_pAppId, TW_UINT16 _MSG, TW_IDENTITY *_pDsId)
 Source operations. More...
 
TW_INT16 CTwnDsm::DSM_TwunkIdentity (TW_IDENTITY *_pAppId, TW_UINT16 _MSG, TW_TWUNKIDENTITY *_pTwunkId)
 This routine will return the path to a DS. More...
 
TW_INT16 CTwnDsm::DSM_Entrypoint (TW_IDENTITY *_pAppId, TW_UINT16 _MSG, TW_ENTRYPOINT *_pEntrypoint)
 Gets entry points. More...
 
TW_INT16 CTwnDsm::DSM_Callback (TW_IDENTITY *_pAppId, TW_IDENTITY *_pDsId, TW_UINT16 _MSG, TW_CALLBACK *_pData)
 Register application's callback. More...
 
TW_INT16 CTwnDsm::DSM_Callback2 (TW_IDENTITY *_pAppId, TW_IDENTITY *_pDsId, TW_UINT16 _MSG, TW_CALLBACK2 *_pData)
 Register application's callback. More...
 
TW_INT16 CTwnDsm::OpenDS (TW_IDENTITY *_pAppId, TW_IDENTITY *_pDsId)
 Opens the Data Source specified by pDSIdentity. More...
 
TW_INT16 CTwnDsm::CloseDS (TW_IDENTITY *_pAppId, TW_IDENTITY *_pDsId)
 Closes the Data Source specified by pDSIdentity. More...
 
TW_INT16 CTwnDsm::DSM_SelectDS (TW_IDENTITY *_pAppId, TW_IDENTITY *_pDsId)
 Displays the source select dialog and sets the default source. More...
 
TW_INT16 CTwnDsm::DSM_SetDefaultDS (TW_IDENTITY *_pAppId, TW_IDENTITY *_pDsId)
 Set the default source. More...
 
TW_INT16 CTwnDsm::GetDSFromProductName (TW_IDENTITY *_pAppId, TW_IDENTITY *_pDsId)
 Goes through the applications supported data sources looking for one that has the exact same name as product name in the passed in identity. More...
 
TW_INT16 CTwnDsm::DSM_GetFirst (TW_IDENTITY *_pAppId, TW_IDENTITY *_pDsId)
 Copies the applications first available source into _pDsId. More...
 
TW_INT16 CTwnDsm::DSM_GetNext (TW_IDENTITY *_pAppId, TW_IDENTITY *_pDsId)
 Copies the applications next available source into _pDsId. More...
 
TW_INT16 CTwnDsm::GetMatchingDefault (TW_IDENTITY *_pAppId, TW_IDENTITY *_pDsId)
 This routine will check if the current default source matches the applications supported groups. More...
 
TW_INT16 CTwnDsm::GetIdentity (TW_IDENTITY *_pAppId, TW_IDENTITY *_pDsId)
 Return back the tw_identity of the current source. More...
 
bool CTwnDsm::printTripletsInfo (const TW_IDENTITY *_pOrigin, const TW_IDENTITY *_pDest, const TW_UINT32 _DG, const TW_UINT16 _DAT, const TW_UINT16 _MSG, const TW_MEMREF _pData)
 prints to stdout information about the triplets. More...
 
void CTwnDsm::printResults (const TW_UINT32 _DG, const TW_UINT16 _DAT, const TW_UINT16 _MSG, const TW_MEMREF _pData, const TW_UINT16 _RC)
 prints to stdout information about result of processing the triplets. More...
 
void CTwnDsm::StringFromMsg (char *_szMsg, const int _nChars, const TW_UINT16 _MSG)
 Translates the _MSG passed in into a string and returns it. More...
 
void CTwnDsm::StringFromDat (char *_szDat, const int _nChars, const TW_UINT16 _DAT)
 Translates the _DAT passed in into a string and returns it. More...
 
void CTwnDsm::StringFromDg (char *_szDg, const int _nChars, const TW_UINT32 _DG)
 Translates the _DG passed in into a string and returns it. More...
 
void CTwnDsm::StringFromCap (char *_szCap, const int _nChars, const TW_UINT16 _Cap)
 Translates the _Cap passed in into a string and returns it. More...
 
void CTwnDsm::StringFromConType (char *_szConType, const int _nChars, const TW_UINT16 _ConType)
 Translates the _ConType and _hContainer passed in into a string and returns it. More...
 
void CTwnDsm::StringFromRC (char *_szRc, const int _nChars, const TW_UINT16 _rc)
 Translates the rc passed in into a string and returns it. More...
 
void CTwnDsm::StringFromConditionCode (char *_szCondCode, const int _nChars, const TW_UINT16 _cc)
 Translates the Condition Code passed in into a string and returns it. More...
 

Variables

CTwnDsmLogImplCTwnDsmLog::m_ptwndsmlogimpl
 The implementation pointer helps with encapulation.
 
CTwnDsmLogg_ptwndsmlog
 The logging object, only access through macros.
 
CTwnDsmAppsImplCTwnDsmApps::m_ptwndsmappsimpl
 The implementation pointer helps with encapulation.
 
CTwnDsmAppsCTwnDsm::_pod::m_ptwndsmapps
 The class takes care of our list of applications and drivers.
 
char CTwnDsm::_pod::m_DefaultDSPath [FILENAME_MAX]
 The path to the default DS. More...
 
TWID_T CTwnDsm::_pod::m_nextDsId
 The next id to test for GetFirst/GetNext...
 
TW_IDENTITYCTwnDsm::_pod::m_pSelectDlgDsId
 The DS ID we end up with from SelectDlgProc. More...
 
TW_IDENTITYCTwnDsm::_pod::m_pSelectDlgAppId
 The Application ID we're using inside of SelectDlgProc. More...
 
struct CTwnDsm::_pod CTwnDsm::pod
 Pieces of Data for the DSM class.
 

Detailed Description

We want to use secure string functions whenever possible, if g++ every includes a set I think it would be excellent to switch over to it, but at least with Windows using them we stand a better chance of finding boo-boos...

Macro Definition Documentation

◆ kLOG

#define kLOG (   a)    if (g_ptwndsmlog) g_ptwndsmlog->Log a

Define to write messages to LogFile.

See also
CTwnDsmLog

Definition at line 496 of file dsm.h.

◆ kPANIC

#define kPANIC (   msg)    ::MessageBox(NULL,msg,"TWAIN Data Source Manager",MB_OK);

Display message to user.

Use this if logging is not an option, and this is the only way to track a problem!!!

See also
kLOG

Definition at line 508 of file dsm.h.

◆ MAX_NUM_DS

#define MAX_NUM_DS   50

Maximum number of Data Sources that can be opened under one application.

This item seems useful, though the number seems rather high.

Definition at line 521 of file dsm.h.

◆ SGETENV

#define SGETENV (   d,
  z,
 
)    ::GetEnvironmentVariable(n,d,z)

Secure Get enviroment varable.

Parameters
[out]ddestination string
[in]zsize of destination in char
[in]nthe source string

Definition at line 404 of file dsm.h.

◆ SSTRCAT

#define SSTRCAT (   d,
  z,
 
)    strncat_s(d,z,s,_TRUNCATE)

Secure String catinate.

Parameters
[out]ddestination string
[in]zsize of destination in char
[in]sthe source string

Definition at line 402 of file dsm.h.

◆ SSTRCPY

#define SSTRCPY (   d,
  z,
 
)    strncpy_s(d,z,s,_TRUNCATE)

Secure String copy.

Parameters
[out]ddestination string
[in]zsize of destination in char
[in]sthe source string

Definition at line 401 of file dsm.h.

◆ SSTRNCPY

#define SSTRNCPY (   d,
  z,
  s,
 
)    strncpy_s(d,z,s,m)

Secure String n copy.

Parameters
[out]ddestination string
[in]zsize of destination in char
[in]sthe source string
[in]mthe number of char to copy

Definition at line 403 of file dsm.h.

Enumeration Type Documentation

◆ DSM_State

enum DSM_State

Possible States of the DSM.

The three possible states of the Data Source Manager. We don't want to know about the other states, because that would add needless complexity.

Enumerator
dsmState_PreSession 

Source Manager not loaded.

dsmState_Loaded 

Source Manager is loaded, but not open.

dsmState_Open 

Source Manager is open.

Definition at line 530 of file dsm.h.

Function Documentation

◆ AddApp()

TW_UINT16 CTwnDsmApps::AddApp ( TW_IDENTITY _pAppId,
TW_MEMREF  _MemRef 
)

Add an application.

This supports MSG_OPENDSM.

Parameters
[out]_pAppIdOrigin of message
[in]_MemRefthe HWND on Window, null otherwise
Returns
a valid TWRC_xxxx return code

Attempt to add an application to our list. Truth be told we only expect an application to do this once, but for legacy's sake we support the ability to do it more than once, but the Application has to provide a unique ProductName in its Identity. If an Application really has to support multiple drivers, then it's recommended that it do this through seperate processes, since their is no guarantee that any two drivers will operator correctly in the same process...

Definition at line 364 of file apps.cpp.

Referenced by CTwnDsm::DSM_Parent().

◆ AppGetConditionCode()

TW_UINT16 CTwnDsmApps::AppGetConditionCode ( TW_IDENTITY _pAppId)

Get the condition code, then reset it internally to TWCC_SUCCESS, so you can only get it once, per the specification...

Return the condition code and clear it internally.

Parameters
[in]_pAppIdid of app, or NULL if we have no apps
Returns
TWCC_ value

Every open application maintains its own conditioncode, which is going to be used in state 3. In state 4 and higher the condition code is coming from the driver. In state 2 there is no condition code, so we have to use a value that is global to this instance of the DSM. The code is cleared internally, per the specification...

Definition at line 619 of file apps.cpp.

References CTwnDsmApps::AppValidateId(), CTwnDsmAppsImpl::m_AppInfo, and CTwnDsmApps::m_ptwndsmappsimpl.

Referenced by CTwnDsm::DSM_Status().

◆ AppGetIdentity()

TW_IDENTITY * CTwnDsmApps::AppGetIdentity ( TW_IDENTITY _pAppId)

Return a pointer to the application's identity.

Validate an application's identity.

Yeah, I know, this sorta violates encapsulation, but we do not want to get silly about this...

Parameters
[in]_pAppIdid of identity to get
Returns
pointer to identity or NULL

Make sure we're dealing with good data...

Definition at line 598 of file apps.cpp.

References CTwnDsmApps::AppValidateId(), CTwnDsmAppsImpl::m_AppInfo, and CTwnDsmApps::m_ptwndsmappsimpl.

◆ AppGetNumApp()

TWID_T CTwnDsmApps::AppGetNumApp ( )

Get number of allocated App slots (Last valid App ID +1)

Returns
number of allocated App slots (Last valid App ID +1)

Definition at line 729 of file apps.cpp.

◆ AppGetNumDs()

TWID_T CTwnDsmApps::AppGetNumDs ( TW_IDENTITY _pAppId)

Get the number of drivers we found as the result of a successful call to LoadDS with _boolKeepOpen set to false (meaning that we were just browsing)...

Get the number of drivers found.

Parameters
[in]_pAppIdid of app
Returns
DSM_State of the application

When LoadDS() is called during AddApp() we browse for drivers and keep the identity for each one we find. This just tells us how many we found...

Definition at line 762 of file apps.cpp.

Referenced by CTwnDsm::DSM_GetFirst(), CTwnDsm::DSM_GetNext(), CTwnDsm::GetMatchingDefault(), and CTwnDsm::SelectDlgProc().

◆ AppGetState() [1/2]

DSM_State CTwnDsmApps::AppGetState ( )

Get the state of the DSM for all applications.

Returns
DSM_State, Open if at least one application has DSM open

Definition at line 688 of file apps.cpp.

References dsmState_PreSession.

Referenced by CTwnDsm::DSMGetState().

◆ AppGetState() [2/2]

DSM_State CTwnDsmApps::AppGetState ( TW_IDENTITY _pAppId)

Get the state of the DSM for the specified application.

Get our current state.

Parameters
[in]_pAppIdid of app
Returns
DSM_State of the application

There are really only two states that the DSM can occupy, state 2 where it's loaded, but hasn't had a MSG_OPENDSM done for the specified application identity. And state 3, where a MSG_OPENDSM has been successfully performed...

Definition at line 710 of file apps.cpp.

References CTwnDsmApps::AppValidateId(), CTwnDsmAppsImpl::m_AppInfo, and CTwnDsmApps::m_ptwndsmappsimpl.

◆ AppHwnd()

void * CTwnDsmApps::AppHwnd ( TW_IDENTITY _pAppId)

Get the hwnd sent in with the call to MSG_OPENDSM.

Get our hwnd.

Parameters
[in]_pAppIdid of app
Returns
hwnd for the application that is calling us

Windows needs this to help center the user select window...

Definition at line 740 of file apps.cpp.

References CTwnDsmApps::AppValidateId(), CTwnDsmAppsImpl::m_AppInfo, and CTwnDsmApps::m_ptwndsmappsimpl.

Referenced by CTwnDsm::SelectDlgProc().

◆ AppSetConditionCode()

void CTwnDsmApps::AppSetConditionCode ( TW_IDENTITY _pAppId,
TW_UINT16  _conditioncode 
)

◆ AppValidateId()

TW_BOOL CTwnDsmApps::AppValidateId ( TW_IDENTITY _pAppId)

Validate that an id is in range...

Validate an application's identity.

Parameters
[in]_pAppIdid of App to test
Returns
TRUE if valid, else FALSE

Make sure we're dealing with good data...

Definition at line 541 of file apps.cpp.

References kLOG, and kLOGERR.

Referenced by CTwnDsmApps::AppGetConditionCode(), CTwnDsmApps::AppGetIdentity(), CTwnDsmApps::AppGetState(), CTwnDsmApps::AppHwnd(), CTwnDsmApps::AppValidateIds(), CTwnDsmApps::AppWakeup(), CTwnDsm::DSM_GetFirst(), CTwnDsm::DSM_GetNext(), and CTwnDsm::GetMatchingDefault().

◆ AppValidateIds()

TW_BOOL CTwnDsmApps::AppValidateIds ( TW_IDENTITY _pAppId,
TW_IDENTITY _pDSId 
)

Validate that the App ID and DS ID are in range...

Validate an application's identity and its DS identity.

Parameters
[in]_pAppIdid of App to test
[in]_pDSIdid of DS to test
Returns
TRUE if valid, else FALSE

Make sure we're dealing with good data...

Definition at line 561 of file apps.cpp.

References CTwnDsmApps::AppValidateId(), kLOG, and kLOGERR.

Referenced by CTwnDsm::DSM_Callback(), CTwnDsm::DSM_Callback2(), CTwnDsm::DSM_Entry(), and CTwnDsm::DSM_Null().

◆ AppWakeup()

void CTwnDsmApps::AppWakeup ( TW_IDENTITY _pAppId)

Poke the application to wake it up when sending a DAT_NULL message to it...

Wakeup an application.

Parameters
[in]_pAppIdid of app

We need this in Windows when we send DAT_NULL to an application, otherwise it'll sit there like a lump on a bog until an event comes along to wake it up so it can process the message.

Definition at line 1893 of file apps.cpp.

References CTwnDsmApps::AppValidateId(), CTwnDsmAppsImpl::m_AppInfo, and CTwnDsmApps::m_ptwndsmappsimpl.

◆ CloseDS()

TW_INT16 CTwnDsm::CloseDS ( TW_IDENTITY _pAppId,
TW_IDENTITY _pDsId 
)
private

Closes the Data Source specified by pDSIdentity.

Parameters
[in]_pAppIdOrigin of message
[in]_pDsIdTW_IDENTITY structure
Returns
a valid TWRC_xxxx return code

Definition at line 1348 of file dsm.cpp.

References CTwnDsmApps::AppSetConditionCode(), kLOG, kLOGERR, CTwnDsm::_pod::m_ptwndsmapps, and CTwnDsm::pod.

◆ CTwnDsmApps()

CTwnDsmApps::CTwnDsmApps ( )

The CTwnDsmApps constructor.

The constructor, where we create our implementation object...

Definition at line 314 of file apps.cpp.

References kLOG, kLOGERR, and CTwnDsmApps::m_ptwndsmappsimpl.

◆ CTwnDsmLog()

CTwnDsmLog::CTwnDsmLog ( )

The CTwnDsmLog constructor.

The constructor for our class.

This is where we see if we have a file in the TWAINDSM_LOG environment variable. If so, then we'll log stuff. If not, then we'll log nothing. TWAINDSM_LOGMODE selects how we open the file. The default value is "w+", which means it's wiped out each time a new session is started. Setting this environmental to "a+" will cause the log information to be appended to an existing file (a new one will still be created if needed...

Definition at line 106 of file log.cpp.

References kLOGENV, kLOGMODEENV, kPANIC, CTwnDsmLogImpl::_pod::m_logmode, CTwnDsmLogImpl::_pod::m_logpath, CTwnDsmLogImpl::_pod::m_message, CTwnDsmLog::m_ptwndsmlogimpl, NCHARS, CTwnDsmLogImpl::pod, SGETENV, SSTRCPY, and TWNDSM_MAX_MSG.

◆ DsCallback2Get()

TW_CALLBACK2 * CTwnDsmApps::DsCallback2Get ( TW_IDENTITY _pAppId,
TWID_T  _DsId 
)

Get a pointer to TW_CALLBACK structure for the specified driver...

Get a point to the TW_CALLBACK2 for the specified driver.

reason...

Parameters
[in]_pAppIdid of app
[in]_DsIdnumeric id of driver
Returns
pointer to the callback structure for this driver or NULL

This is optional for drivers on Windows. On Linux it's the only way to use DAT_NULL to let an Application know about messages going from the Driver to the Application

Definition at line 860 of file apps.cpp.

Referenced by CTwnDsm::DSM_Callback(), CTwnDsm::DSM_Callback2(), and CTwnDsm::DSM_Null().

◆ DsCallbackIsWaiting()

TW_BOOL CTwnDsmApps::DsCallbackIsWaiting ( TW_IDENTITY _pAppId,
TWID_T  _DsId 
)

Test if the driver has a callback pending for attention...

Check if a callback is waiting.

Parameters
[in]_pAppIdid of app
[in]_DsIdnumeric id of driver
Returns
TRUE if the driver needs its callback called

This allows the DSM to help a driver get its message to an application...

Definition at line 885 of file apps.cpp.

Referenced by CTwnDsm::DSM_Entry().

◆ DsCallbackSetWaiting()

void CTwnDsmApps::DsCallbackSetWaiting ( TW_IDENTITY _pAppId,
TWID_T  _DsId,
TW_BOOL  _Waiting 
)

Set the callback flag for the driver to TRUE if the callback needs to have its callback called, and set it to FALSE after the call has been made...

Set the callback flag.

Parameters
[in]_pAppIdid of app
[in]_DsIdnumeric id of driver
[in]_Waitingthe new state for the waiting flag

This is how we know when we have something for the Application...

Definition at line 909 of file apps.cpp.

◆ DsGetEntryProc()

DSENTRYPROC CTwnDsmApps::DsGetEntryProc ( TW_IDENTITY _pAppId,
TWID_T  _DsId 
)

Get a pointer to the DS_Entry function of the specified driver...

Get the DS_Entry function for the specified driver.

Parameters
[in]_pAppIdid of app
[in]_DsIdnumeric id of driver
Returns
pointer to DS_Entry for this driver or NULL

Every driver has to have one of these...

Definition at line 809 of file apps.cpp.

◆ DsGetIdentity()

TW_IDENTITY * CTwnDsmApps::DsGetIdentity ( TW_IDENTITY _pAppId,
TWID_T  _DsId 
)

Get a pointer to the identity of the specified driver...

Get the identity for the specified driver.

Parameters
[in]_pAppIdid of app
[in]_DsIdnumeric id of driver
Returns
pointer to drivers identity or NULL

When LoadDS() is called during AddApp() we browse for drivers and keep the identity for each one we find. This just tells us how many we found...

Definition at line 785 of file apps.cpp.

Referenced by CTwnDsm::DSM_GetFirst(), CTwnDsm::DSM_GetNext(), and CTwnDsm::SelectDlgProc().

◆ DsGetPath()

char * CTwnDsmApps::DsGetPath ( TW_IDENTITY _pAppId,
TWID_T  _DsId 
)

Get a pointer to the driver file path and name, which is guaranteed to be unique, even if the ProductName's aren't for some horrible reason...

Get the full path and filename for the specified driver.

Parameters
[in]_pAppIdid of app
[in]_DsIdnumeric id of driver
Returns
pointer to file path and name for this driver or NULL

We use this to uniquely identify each driver, since the ProductName is not guaranteed to be unique, though it should be...

Definition at line 834 of file apps.cpp.

Referenced by CTwnDsm::SelectDlgProc().

◆ DsIsAppProcessingCallback()

TW_BOOL CTwnDsmApps::DsIsAppProcessingCallback ( TW_IDENTITY _pAppId,
TWID_T  _DsId 
)

Check if the App is still processing last callback.

Parameters
[in]_pAppIdid of app
[in]_DsIdnumeric id of driver
Returns
TRUE if the App has not finished processing callback

This allows the DSM to prevent the app from calling the DS with a
message before it returns from recieving the last callback.

Definition at line 982 of file apps.cpp.

◆ DsIsProcessingMessage()

TW_BOOL CTwnDsmApps::DsIsProcessingMessage ( TW_IDENTITY _pAppId,
TWID_T  _DsId 
)

Check if the DS is still processing last message.

Parameters
[in]_pAppIdid of app
[in]_DsIdnumeric id of driver
Returns
TRUE if the DS has not finished processing message

This allows the DSM to prevent DS from recieving a new message when they have not finished the current

Definition at line 934 of file apps.cpp.

◆ DSM_Callback()

TW_INT16 CTwnDsm::DSM_Callback ( TW_IDENTITY _pAppId,
TW_IDENTITY _pDsId,
TW_UINT16  _MSG,
TW_CALLBACK _pData 
)
private

Register application's callback.

Parameters
[in]_pAppIdOrigin of message
[in]_pDsIdTW_IDENTITY structure
[in]_MSGmessage id: MSG_xxxx valid = MSG_REGISTER_CALLBACK
[in]_pDatapointer to a callback struct
Returns
a valid TWRC_xxxx return code

Definition at line 973 of file dsm.cpp.

References CTwnDsmApps::AppSetConditionCode(), CTwnDsmApps::AppValidateIds(), CTwnDsmApps::DsCallback2Get(), kLOG, kLOGERR, CTwnDsm::_pod::m_ptwndsmapps, and CTwnDsm::pod.

◆ DSM_Callback2()

TW_INT16 CTwnDsm::DSM_Callback2 ( TW_IDENTITY _pAppId,
TW_IDENTITY _pDsId,
TW_UINT16  _MSG,
TW_CALLBACK2 _pData 
)
private

Register application's callback.

Parameters
[in]_pAppIdOrigin of message
[in]_pDsIdTW_IDENTITY structure
[in]_MSGmessage id: MSG_xxxx valid = MSG_REGISTER_CALLBACK
[in]_pDatapointer to a callback2 struct
Returns
a valid TWRC_xxxx return code

Definition at line 1055 of file dsm.cpp.

References CTwnDsmApps::AppSetConditionCode(), CTwnDsmApps::AppValidateIds(), CTwnDsmApps::DsCallback2Get(), kLOG, kLOGERR, CTwnDsm::_pod::m_ptwndsmapps, and CTwnDsm::pod.

◆ DSM_Entry()

TW_UINT16 CTwnDsm::DSM_Entry ( TW_IDENTITY _pOrigin,
TW_IDENTITY _pDest,
TW_UINT32  _DG,
TW_UINT16  _DAT,
TW_UINT16  _MSG,
TW_MEMREF  _pData 
)

The guts of the DSM_Entry, the resource management portion resides in a our DSM_Entry entry point, which isn't a part of this class.

Hopefully it's not confusing that they have the same name...

Parameters
[in]_pOriginOrigin of message in this case a DS
[in]_pDestdestination of message in this case an App
[in]_DGmessage id: DG_xxxx
[in]_DATmessage id: DAT_xxxx
[in]_MSGmessage id: MSG_xxxx
[in]_pDatathe Data
Returns
a valid TWRC_xxxx return code

Definition at line 447 of file dsm.cpp.

References CTwnDsmApps::AppSetConditionCode(), CTwnDsmApps::AppValidateIds(), CTwnDsmApps::DsCallbackIsWaiting(), kLOG, kLOGINFO, CTwnDsm::_pod::m_ptwndsmapps, CTwnDsm::pod, and CTwnDsm::printTripletsInfo().

Referenced by DSM_Entry(), and CTwnDsm::DSM_Entrypoint().

◆ DSM_Entrypoint()

TW_INT16 CTwnDsm::DSM_Entrypoint ( TW_IDENTITY _pAppId,
TW_UINT16  _MSG,
TW_ENTRYPOINT _pEntrypoint 
)
private

Gets entry points.

Parameters
[in]_pAppIdOrigin of message
[in]_MSGmessage id: MSG_xxxx
[out]_pEntrypointTW_IDENTITY structure
Returns
a valid TWRC_xxxx return code

Definition at line 893 of file dsm.cpp.

References CTwnDsmApps::AppSetConditionCode(), CTwnDsm::DSM_Entry(), kLOG, kLOGERR, CTwnDsm::_pod::m_ptwndsmapps, and CTwnDsm::pod.

◆ DSM_GetFirst()

TW_INT16 CTwnDsm::DSM_GetFirst ( TW_IDENTITY _pAppId,
TW_IDENTITY _pDsId 
)
private

Copies the applications first available source into _pDsId.

Parameters
[in]_pAppIdThe origin identity structure
[out]_pDsIdthe identity structure to copy data into
Returns
a valid TWRC_xxxx return code
Todo:
scanDSDir needs to be done with each MSG_GETFIRST
currently we are only scanDSDir when an App opens the DSM

Definition at line 2113 of file dsm.cpp.

References CTwnDsmApps::AppGetNumDs(), CTwnDsmApps::AppSetConditionCode(), CTwnDsmApps::AppValidateId(), CTwnDsmApps::DsGetIdentity(), kLOG, kLOGERR, CTwnDsm::_pod::m_nextDsId, CTwnDsm::_pod::m_ptwndsmapps, and CTwnDsm::pod.

◆ DSM_GetNext()

TW_INT16 CTwnDsm::DSM_GetNext ( TW_IDENTITY _pAppId,
TW_IDENTITY _pDsId 
)
private

Copies the applications next available source into _pDsId.

A call to DSM_GetFirst must have been made at least once before calling this function.

Parameters
[in]_pAppIdThe origin identity structure
[out]_pDsIdthe identity structure to copy data into
Returns
a valid TWRC_xxxx return code

Definition at line 2158 of file dsm.cpp.

References CTwnDsmApps::AppGetNumDs(), CTwnDsmApps::AppSetConditionCode(), CTwnDsmApps::AppValidateId(), CTwnDsmApps::DsGetIdentity(), kLOG, kLOGERR, CTwnDsm::_pod::m_nextDsId, CTwnDsm::_pod::m_ptwndsmapps, and CTwnDsm::pod.

◆ DSM_Identity()

TW_INT16 CTwnDsm::DSM_Identity ( TW_IDENTITY _pAppId,
TW_UINT16  _MSG,
TW_IDENTITY _pDsId 
)
private

Source operations.

Parameters
[in]_pAppIdOrigin of message
[in]_MSGmessage id: MSG_xxxx
[in]_pDsIdTW_IDENTITY structure
Returns
a valid TWRC_xxxx return code

Definition at line 772 of file dsm.cpp.

◆ DSM_LoadFunction()

void* DSM_LoadFunction ( void *  _pHandle,
const char *  _pszSymbol 
)

This function wraps the function loading calls.

Linux has a special way to check dlsym failures.

Definition at line 3892 of file dsm.cpp.

References kLOG, kLOGERR, and LOADFUNCTION.

◆ DSM_Null()

TW_INT16 CTwnDsm::DSM_Null ( TW_IDENTITY _pAppId,
TW_IDENTITY _pDsId,
TW_UINT16  _MSG 
)
private

Handles DAT_NULL calls from DS for Application.

Parameters
[in]_pAppIdOrigin of message
[in]_pDsIdTW_IDENTITY structure
[in]_MSGmessage id: MSG_xxxx
Returns
a valid TWRC_xxxx return code

Definition at line 2453 of file dsm.cpp.

References CTwnDsmApps::AppSetConditionCode(), CTwnDsmApps::AppValidateIds(), CTwnDsmApps::DsCallback2Get(), kLOG, kLOGERR, CTwnDsm::_pod::m_ptwndsmapps, and CTwnDsm::pod.

◆ DSM_Parent()

TW_INT16 CTwnDsm::DSM_Parent ( TW_IDENTITY _pAppId,
TW_UINT16  _MSG,
TW_MEMREF  _MemRef 
)
private

Initializes or closes the DSM.

Parameters
[in]_pAppIdOrgin of message
[in]_MSGmessage id: MSG_xxxx
[in]_MemReffor Windows during MSG_OPENDSM it is HWND, null otherwise
Returns
a valid TWRC_xxxx return code

Definition at line 726 of file dsm.cpp.

References CTwnDsmApps::AddApp(), CTwnDsmApps::AppSetConditionCode(), kLOG, kLOGERR, CTwnDsm::_pod::m_ptwndsmapps, CTwnDsm::pod, and CTwnDsmApps::RemoveApp().

◆ DSM_SelectDS()

TW_INT16 CTwnDsm::DSM_SelectDS ( TW_IDENTITY _pAppId,
TW_IDENTITY _pDsId 
)
private

Displays the source select dialog and sets the default source.

Parameters
[in]_pAppIdOrigin of message
[in,out]_pDsIdTW_IDENTITY structure
Returns
a valid TWRC_xxxx return code
Todo:
scanDSDir needs to be done with each MSG_USERSELECT
currently we are only scanDSDir when an App opens the DSM

Definition at line 1800 of file dsm.cpp.

References CTwnDsmApps::AppSetConditionCode(), kLOG, kLOGERR, CTwnDsm::_pod::m_ptwndsmapps, and CTwnDsm::pod.

◆ DSM_SetDefaultDS()

TW_INT16 CTwnDsm::DSM_SetDefaultDS ( TW_IDENTITY _pAppId,
TW_IDENTITY _pDsId 
)
private

Set the default source.

Parameters
[in]_pAppIdOrigin of message
[in]_pDsIdTW_IDENTITY structure
Returns
a valid TWRC_xxxx return code

Definition at line 1955 of file dsm.cpp.

References CTwnDsmApps::AppSetConditionCode(), kLOG, kLOGERR, CTwnDsm::_pod::m_ptwndsmapps, and CTwnDsm::pod.

◆ DSM_Status()

TW_INT16 CTwnDsm::DSM_Status ( TW_IDENTITY _pAppId,
TW_UINT16  _MSG,
TW_STATUS _pStatus 
)
private

Returns the current DSM status.

Resets pod.m_ConditionCode to TWCC_SUCCESS per the specification.

Parameters
[in]_pAppIdOrgin of message
[in]_MSGmessage id: MSG_xxxx
[out]_pStatusTW_STATUS structure
Returns
a valid TWRC_xxxx return code

Definition at line 696 of file dsm.cpp.

References CTwnDsmApps::AppGetConditionCode(), CTwnDsmApps::AppSetConditionCode(), CTwnDsm::_pod::m_ptwndsmapps, and CTwnDsm::pod.

◆ DSM_TwunkIdentity()

TW_INT16 CTwnDsm::DSM_TwunkIdentity ( TW_IDENTITY _pAppId,
TW_UINT16  _MSG,
TW_TWUNKIDENTITY _pTwunkId 
)
private

This routine will return the path to a DS.


This is here for backwards compatibility. DAT_TWUNKIDENTITY is undocumented. It was used by the Twunking layer. Some old applications use it to get the path to the DS. We need to continue to support it.

Parameters
[in]_pAppIdOrigin of message
[in]_MSGmessage id: MSG_GET
[in,out]_pTwunkIdTW_TWUNKIDENTITY structure with a valid TW_IDENTITY, returns path
Returns
a valid TWRC_xxxx return code

Definition at line 843 of file dsm.cpp.

◆ DSMGetState()

DSM_State CTwnDsm::DSMGetState ( )

Get the state of the DSM by checking the state of all applications.

Returns
DSM_State, Open if at least one application has DSM open

Definition at line 683 of file dsm.cpp.

References CTwnDsmApps::AppGetState(), CTwnDsm::_pod::m_ptwndsmapps, and CTwnDsm::pod.

Referenced by DllMain(), and DSM_Entry().

◆ DsSetAppProcessingCallback()

void CTwnDsmApps::DsSetAppProcessingCallback ( TW_IDENTITY _pAppId,
TWID_T  _DsId,
TW_BOOL  _Processing 
)

Set the AppProcessingCallback flag.

This is how we know the App is not done processing the previous callback

Parameters
[in]_pAppIdid of app
[in]_DsIdnumeric id of driver
[in]_Processingthe new state for the processing flag

This is how we know the App is not done processing the previous callback

Definition at line 1005 of file apps.cpp.

◆ DsSetProcessingMessage()

void CTwnDsmApps::DsSetProcessingMessage ( TW_IDENTITY _pAppId,
TWID_T  _DsId,
TW_BOOL  _Processing 
)

Set the ProcessingMessage flag.

This is how we know the DS is not done processing the previous message

Parameters
[in]_pAppIdid of app
[in]_DsIdnumeric id of driver
[in]_Processingthe new state for the processing flag

This is how we know the DS is not done processing the previous message

Definition at line 958 of file apps.cpp.

◆ GetDSFromProductName()

TW_INT16 CTwnDsm::GetDSFromProductName ( TW_IDENTITY _pAppId,
TW_IDENTITY _pDsId 
)
private

Goes through the applications supported data sources looking for one that has the exact same name as product name in the passed in identity.

Will update the _pDsId structure to match the name.

Parameters
[in]_pAppIdOrigin of message
[in,out]_pDsIdTW_IDENTITY structure
Returns
a valid TWRC_xxxx return code

Definition at line 2072 of file dsm.cpp.

◆ GetIdentity()

TW_INT16 CTwnDsm::GetIdentity ( TW_IDENTITY _pAppId,
TW_IDENTITY _pDsId 
)
private

Return back the tw_identity of the current source.

In state 3 this will be the default source. In state 4 this will be the currently opened source.

Parameters
[in]_pAppIdThe application identity
[in,out]_pDsIdA pointer reference that will be set to point to the current identity.
Returns
a valid TWRC_xxxx return code

◆ GetMatchingDefault()

TW_INT16 CTwnDsm::GetMatchingDefault ( TW_IDENTITY _pAppId,
TW_IDENTITY _pDsId 
)
private

This routine will check if the current default source matches the applications supported groups.

If it does it will copy it into the default Source's identity (_pDsId), otherwise this routine will search for a source that does match the app's supported groups and copy it into _pDsId.

Parameters
[in]_pAppIdThe application identity
[in,out]_pDsIdA pointer reference that will be set to point to the default identity.
Returns
a valid TWRC_xxxx return code

Definition at line 2199 of file dsm.cpp.

References CTwnDsmApps::AppGetNumDs(), CTwnDsmApps::AppSetConditionCode(), CTwnDsmApps::AppValidateId(), kLOG, kLOGERR, CTwnDsm::_pod::m_ptwndsmapps, and CTwnDsm::pod.

◆ LoadDS()

TW_INT16 CTwnDsmApps::LoadDS ( TW_IDENTITY _pAppId,
TWID_T  _DsId 
)

Loads a DS from disk and adds it to a global list of DS's.

Load a specific driver.

Parameters
[in]_pAppIdOrigin of message
[in]_DsIdthe source index of the library to open
Returns
a valid TWRC_xxxx return code

This is the interface function that's called by CTwnDsm

Definition at line 1380 of file apps.cpp.

◆ Log()

void CTwnDsmLog::Log ( const int  _doassert,
const char *const  _file,
const int  _line,
const char *const  _format,
  ... 
)

The logging function.

Logging function.

This should only be access through the kLOG macro...

Parameters
[in]_doassertdecides if we assert or not
[in]_filethe source file of the message
[in]_linethe source line of the message
[in]_formatthe format of the message (same as sprintf)
[in]...arguments to the format of the message

We provide a timestamp from hours to milliseconds, which can be used to help with performance, and to detect large, unexpected idle times. The filename and line number in the source code is provided. GetLastError or errno may offer a hint about a problem with a system call, but be careful, since it's not cleared and so it may report a message that has nothing to do with the current calls, or anything going on in the DSM. The id of the thread that called us is useful for finding problems with unsafe use, or use that crosses thread boundaries in a bad way (like on Windows, when one has to stay in the same thread as the HWND if the DAT_NULL messages are going to work)...

Definition at line 173 of file log.cpp.

References FOPEN, GETTHREADID, CTwnDsmLogImpl::_pod::m_logmode, CTwnDsmLogImpl::_pod::m_logpath, CTwnDsmLogImpl::_pod::m_message, CTwnDsmLogImpl::_pod::m_nIndent, CTwnDsmLogImpl::_pod::m_plog, CTwnDsmLog::m_ptwndsmlogimpl, CTwnDsmLogImpl::pod, SNPRINTF, TWNDSM_CMP_VERSION, and TWNDSM_MAX_MSG.

◆ OpenDS()

TW_INT16 CTwnDsm::OpenDS ( TW_IDENTITY _pAppId,
TW_IDENTITY _pDsId 
)
private

Opens the Data Source specified by pDSIdentity.


pDSIdentity must be valid, but if a null name and id is 0 then open default.

Parameters
[in]_pAppIdOrigin of message
[in]_pDsIdTW_IDENTITY structure
Returns
a valid TWRC_xxxx return code

Definition at line 1134 of file dsm.cpp.

References CTwnDsmApps::AppSetConditionCode(), kLOG, kLOGERR, CTwnDsm::_pod::m_ptwndsmapps, and CTwnDsm::pod.

◆ printResults()

void CTwnDsm::printResults ( const TW_UINT32  _DG,
const TW_UINT16  _DAT,
const TW_UINT16  _MSG,
const TW_MEMREF  _pData,
const TW_UINT16  _RC 
)
private

prints to stdout information about result of processing the triplets.

Parameters
[in]_DGthe Data Group
[in]_DATthe Data Argument Type
[in]_MSGthe Message
[in]_pDatathe Data
[in]_RCthe Return Code after

Definition at line 2402 of file dsm.cpp.

References NCHARS, SSTRCAT, CTwnDsm::StringFromConType(), and CTwnDsm::StringFromRC().

◆ printTripletsInfo()

bool CTwnDsm::printTripletsInfo ( const TW_IDENTITY _pOrigin,
const TW_IDENTITY _pDest,
const TW_UINT32  _DG,
const TW_UINT16  _DAT,
const TW_UINT16  _MSG,
const TW_MEMREF  _pData 
)
private

prints to stdout information about the triplets.

Parameters
[in]_pOriginthe Orgin to print the Product Name
[in]_pDestthe Destination to print the Product Name
[in]_DGthe Data Group
[in]_DATthe Data Argument Type
[in]_MSGthe Message
[in]_pDatathe Data
Returns
return true if actually printed triplet

Definition at line 2328 of file dsm.cpp.

References g_ptwndsmlog, CTwnDsmLog::Indent(), kLOG, kLOGINFO, NCHARS, SSTRCAT, CTwnDsm::StringFromCap(), CTwnDsm::StringFromConType(), CTwnDsm::StringFromDat(), CTwnDsm::StringFromDg(), and CTwnDsm::StringFromMsg().

Referenced by CTwnDsm::DSM_Entry().

◆ RemoveApp()

TW_UINT16 CTwnDsmApps::RemoveApp ( TW_IDENTITY _pAppId)

Remove an application.

This supports MSG_CLOSEDSM.

Parameters
[in]_pAppIdOrigin of message
Returns
a valid TWRC_xxxx return code

Attempt to remove an application to our list.

Definition at line 465 of file apps.cpp.

Referenced by CTwnDsm::DSM_Parent().

◆ SelectDlgProc()

BOOL CTwnDsm::SelectDlgProc ( HWND  _hWnd,
UINT  _Message,
WPARAM  _wParam,
LPARAM  _lParam 
)

Selection dialog, for apps that don't want to do GetFirst GetNext.

This is only public because of the way that dialogs are implemented.

Parameters
[in]_hWndWindow handle of the dialog
[in]_Messagemessage
[in]_wParamwparam
[in]_lParamlparam
Returns
FALSE if we processed the message

Definition at line 1517 of file dsm.cpp.

References CTwnDsmApps::AppGetNumDs(), CTwnDsmApps::AppHwnd(), TwLocalize::Cancel, TwLocalize::CharSet, CTwnDsmApps::DsGetIdentity(), CTwnDsmApps::DsGetPath(), EnumChildProc(), TwLocalize::LangId, TwLocalize::Language, CTwnDsm::_pod::m_DefaultDSPath, CTwnDsm::_pod::m_pSelectDlgAppId, CTwnDsm::_pod::m_pSelectDlgDsId, CTwnDsm::_pod::m_ptwndsmapps, MAX_NUM_DS, CTwnDsm::pod, s_twlocalize, TwLocalize::Select, TwLocalize::Sources, and TwLocalize::Title.

Referenced by SelectDlgProc().

◆ StringFromCap()

void CTwnDsm::StringFromCap ( char *  _szCap,
const int  _nChars,
const TW_UINT16  _Cap 
)
private

Translates the _Cap passed in into a string and returns it.

Parameters
[out]_szCapstring to copy into
[in]_nCharsmax chars in _szCap
[in]_Capthe TWAIN Capability to translate

Definition at line 2924 of file dsm.cpp.

Referenced by CTwnDsm::printTripletsInfo().

◆ StringFromConditionCode()

void CTwnDsm::StringFromConditionCode ( char *  _szCondCode,
const int  _nChars,
const TW_UINT16  _cc 
)
private

Translates the Condition Code passed in into a string and returns it.

Parameters
[out]_szCondCodestring to copy into
[in]_nCharsmax chars in szRc
[in]_ccthe TWAIN Condition Code to translate

Definition at line 3615 of file dsm.cpp.

◆ StringFromConType()

void CTwnDsm::StringFromConType ( char *  _szConType,
const int  _nChars,
const TW_UINT16  _ConType 
)
private

Translates the _ConType and _hContainer passed in into a string and returns it.

Parameters
[out]_szConTypestring to copy into
[in]_nCharsmax chars in _szCap
[in]_ConTypethe TWAIN Container Type to translate

Definition at line 3580 of file dsm.cpp.

Referenced by CTwnDsm::printResults(), and CTwnDsm::printTripletsInfo().

◆ StringFromDat()

void CTwnDsm::StringFromDat ( char *  _szDat,
const int  _nChars,
const TW_UINT16  _DAT 
)
private

Translates the _DAT passed in into a string and returns it.

Parameters
[out]_szDatstring to copy into
[in]_nCharsmax chars in _szDat
[in]_DATthe TWAIN data argument type to translate

Definition at line 2589 of file dsm.cpp.

Referenced by CTwnDsm::printTripletsInfo().

◆ StringFromDg()

void CTwnDsm::StringFromDg ( char *  _szDg,
const int  _nChars,
const TW_UINT32  _DG 
)
private

Translates the _DG passed in into a string and returns it.

Parameters
[out]_szDgstring to copy into
[in]_nCharsmax chars in _szDg
[in]_DGthe TWAIN data group to translate

Definition at line 2560 of file dsm.cpp.

Referenced by CTwnDsm::printTripletsInfo().

◆ StringFromMsg()

void CTwnDsm::StringFromMsg ( char *  _szMsg,
const int  _nChars,
const TW_UINT16  _MSG 
)
private

Translates the _MSG passed in into a string and returns it.

Parameters
[out]_szMsgstring to copy into
[in]_nCharsmax chars in _szMsg
[in]_MSGthe TWAIN message to translate

Definition at line 2749 of file dsm.cpp.

Referenced by CTwnDsm::printTripletsInfo().

◆ StringFromRC()

void CTwnDsm::StringFromRC ( char *  _szRc,
const int  _nChars,
const TW_UINT16  _rc 
)
private

Translates the rc passed in into a string and returns it.

Parameters
[out]_szRcstring to copy into
[in]_nCharsmax chars in szRc
[in]_rcthe TWAIN Return Code to translate

Definition at line 3525 of file dsm.cpp.

Referenced by CTwnDsm::printResults().

◆ UnloadDS()

void CTwnDsmApps::UnloadDS ( TW_IDENTITY _pAppId,
TWID_T  _DsId 
)

Unloads a DS and frees all its resources...

Unload a specific driver.

Parameters
[in]_pAppIdOrigin of message
[in]_DsIdthe source index

I don't care if the called sends this function a bouquet of pink bunnies, I think that close type functions shouldn't fail (unless, of course they're doing something vital, in which case that vital activity shouldn't be in the close function in the first place – so there)...

Definition at line 1853 of file apps.cpp.

◆ ~CTwnDsmApps()

CTwnDsmApps::~CTwnDsmApps ( )

The CTwnDsmApps destructor.

The destructor, where we destroy our implementation object...

Definition at line 328 of file apps.cpp.

References CTwnDsmApps::m_ptwndsmappsimpl.

◆ ~CTwnDsmLog()

CTwnDsmLog::~CTwnDsmLog ( )

The CTwnDsmLog destructor.

The destructor for our class.

Make sure the log is closed, free the buffer and destroy our implementation class...

Definition at line 139 of file log.cpp.

References CTwnDsmLogImpl::_pod::m_message, CTwnDsmLogImpl::_pod::m_plog, CTwnDsmLog::m_ptwndsmlogimpl, and CTwnDsmLogImpl::pod.

Variable Documentation

◆ m_DefaultDSPath

char CTwnDsm::_pod::m_DefaultDSPath[FILENAME_MAX]

The path to the default DS.

The Default DS is identified when the DSM is opened. A new Default is saved if SelectDlg is used. So this value will be compared against DsGetPath()...

Definition at line 1248 of file dsm.h.

Referenced by CTwnDsm::SelectDlgProc().

◆ m_pSelectDlgAppId

TW_IDENTITY* CTwnDsm::_pod::m_pSelectDlgAppId

The Application ID we're using inside of SelectDlgProc.

This is only used on the Windows platform.

Definition at line 1265 of file dsm.h.

Referenced by CTwnDsm::SelectDlgProc().

◆ m_pSelectDlgDsId

TW_IDENTITY* CTwnDsm::_pod::m_pSelectDlgDsId

The DS ID we end up with from SelectDlgProc.

This is only used on the Windows platform.

Definition at line 1259 of file dsm.h.

Referenced by CTwnDsm::SelectDlgProc().