00001
00002
00003
00004
00005
00006
00007
00008
00039 #include <winsock2.h>
00040 #include <bthdef.h>
00041 #include <Bthsdpdef.h>
00042 #include <BluetoothAPIs.h>
00043 #include <Ws2bth.h>
00044 #include <stdio.h>
00045 #include <strsafe.h>
00046
00047 #include "obex.h"
00048 #include "obex_util.h"
00049
00050 #include "parseOpts.h"
00051
00052 #ifdef __cplusplus
00053 extern "C" {
00054 #endif
00055
00056 #include "libxml/parser.h"
00057 #include "libxml/tree.h"
00058 #include "libxml/xmlstring.h"
00059
00060 #define OPPTOOL_EXIT_SUCCESS 0
00061 #define OPPTOOL_EXIT_ERROR_GENERIC -1
00062 #define OPPTOOL_EXIT_ERROR_ALLOC -2
00063 #define OPPTOOL_EXIT_ERROR_OPTIONS -3
00064 #define OPPTOOL_EXIT_ERROR_BT_CONNECTION -4
00065 #define OPPTOOL_EXIT_ERROR_BT_SESSION -5
00066 #define OPPTOOL_EXIT_ERROR_INTERNAL_PARAM -6
00067
00068 #define OPPTOOL_MAX_STD_FILENAME 50
00069
00070
00071
00072
00074 typedef enum
00075 {
00076 OPPTOOL_OPERATION_MODE_UNKNOWN = 0,
00077
00078 OPPTOOL_OPERATION_MODE_PULL_FILES = 1,
00079 OPPTOOL_OPERATION_MODE_PULL_ALL,
00080 OPPTOOL_OPERATION_MODE_PULL_STD,
00081 OPPTOOL_OPERATION_MODE_PULL_VCARD,
00082
00083 OPPTOOL_OPERATION_MODE_PUSH_FILES,
00084 OPPTOOL_OPERATION_MODE_PUSH_DIRECTORY,
00085
00086 } OppToolOperationMode;
00087
00088
00089
00090
00092 typedef struct _Listing
00093 {
00095 dword count;
00096
00098 wchar_t** list;
00099 } Listing;
00100
00101
00102
00103
00105 typedef struct _OppToolContext
00106 {
00108 BluetoothAddress remoteAddress;
00109
00111 BTConnection* connection;
00112
00114 ObexSession* session;
00115
00117 HANDLE btAuthReg;
00118
00120 OBEX_UUID connectionService;
00121
00123 OBEX_UUID* sessionTarget;
00124
00126 int connectionChannel;
00127
00129 Listing filesListing;
00130
00131
00132 struct parseoptsOptionStruct myOpts;
00133
00135 OppToolOperationMode operationMode;
00136
00138 wchar_t* inputDirectory;
00139
00141 int fileCount;
00142
00144 int folderCount;
00145
00146 } OppToolContext;
00147
00148
00155 void clearListing( Listing* list );
00156
00157
00158
00166 void appendListing( Listing* list, wchar_t* item );
00167
00168
00169
00184 int createFileListingFromDirectory( Listing* fileListing, wchar_t* directory, int *files, int *folders );
00185
00186
00187
00201 int createFileListingFromSubDirectory( Listing* fileListing, wchar_t* directory, int *files, int *folders );
00202
00203
00204
00218 int createFileAndFolderListing( xmlDoc* document, Listing* fileListing, Listing* folderListing );
00219
00220
00221
00233 int createPathListing( Listing* folderListing, wchar_t* path );
00234
00235
00236
00250 int createFileListing( Listing* fileListing, char* fileString );
00251
00252
00253
00267 int pullAllFolder( ObexSession* session, wchar_t* remoteFolder, wchar_t *lastFolder , wchar_t* fullRemoteFolder);
00268
00269
00270
00281 int pushAllFolder( OppToolContext *oppToolContext );
00282
00283
00284
00292 BOOL CtrlHandler( DWORD fdwCtrlType );
00293
00294
00295
00301 void printHelp( void );
00302
00303
00304
00318 BOOL authenticationFunction( LPVOID* param, BLUETOOTH_DEVICE_INFO* bdi );
00319
00320
00321
00328 void cleanupOppToolContext( OppToolContext* oppToolContext );
00329
00330
00331
00344 int validateProgramParameters( OppToolContext* oppToolContext );
00345
00346
00347
00354 const char* ErrorMessage( int error );
00355 const wchar_t* ErrorMessageW( int error );
00356
00357 #ifdef __cplusplus
00358 }
00359 #endif