opptool.h File Reference

#include <winsock2.h>
#include <bthdef.h>
#include <Bthsdpdef.h>
#include <BluetoothAPIs.h>
#include <Ws2bth.h>
#include <stdio.h>
#include <strsafe.h>
#include "obex.h"
#include "obex_util.h"
#include "parseOpts.h"
#include "libxml/parser.h"
#include "libxml/tree.h"
#include "libxml/xmlstring.h"

Go to the source code of this file.

Data Structures

struct  _Listing
struct  _OppToolContext

Defines

#define OPPTOOL_EXIT_ERROR_ALLOC   -2
#define OPPTOOL_EXIT_ERROR_BT_CONNECTION   -4
#define OPPTOOL_EXIT_ERROR_BT_SESSION   -5
#define OPPTOOL_EXIT_ERROR_GENERIC   -1
#define OPPTOOL_EXIT_ERROR_INTERNAL_PARAM   -6
#define OPPTOOL_EXIT_ERROR_OPTIONS   -3
#define OPPTOOL_EXIT_SUCCESS   0
#define OPPTOOL_MAX_STD_FILENAME   50

Typedefs

typedef _Listing Listing
typedef _OppToolContext OppToolContext

Enumerations

enum  OppToolOperationMode {
  OPPTOOL_OPERATION_MODE_UNKNOWN = 0, OPPTOOL_OPERATION_MODE_PULL_FILES = 1, OPPTOOL_OPERATION_MODE_PULL_ALL, OPPTOOL_OPERATION_MODE_PULL_STD,
  OPPTOOL_OPERATION_MODE_PULL_VCARD, OPPTOOL_OPERATION_MODE_PUSH_FILES, OPPTOOL_OPERATION_MODE_PUSH_DIRECTORY
}

Functions

void appendListing (Listing *list, wchar_t *item)
 append listing
BOOL authenticationFunction (LPVOID *param, BLUETOOTH_DEVICE_INFO *bdi)
 callback function for authenticating remote device
void cleanupOppToolContext (OppToolContext *oppToolContext)
 Cleanup the opptool context.
void clearListing (Listing *list)
 clear listing
int createFileAndFolderListing (xmlDoc *document, Listing *fileListing, Listing *folderListing)
 create listing from folder-listing xml document
int createFileListing (Listing *fileListing, char *fileString)
 list filenames from --files commandline parameter
int createFileListingFromDirectory (Listing *fileListing, wchar_t *directory, int *files, int *folders)
 create listing from local directory
int createFileListingFromSubDirectory (Listing *fileListing, wchar_t *directory, int *files, int *folders)
 create listing from local sub directory
int createPathListing (Listing *folderListing, wchar_t *path)
 create list of path folders and filename
BOOL CtrlHandler (DWORD fdwCtrlType)
 close program when CTRL-C pressed
const char * ErrorMessage (int error)
 Converts integer type return value to corresponding literal error string.
const wchar_t * ErrorMessageW (int error)
void printHelp (void)
 Print help text.
int pullAllFolder (ObexSession *session, wchar_t *remoteFolder, wchar_t *lastFolder, wchar_t *fullRemoteFolder)
 pulls all files from remote folder
int pushAllFolder (OppToolContext *oppToolContext)
 Push all files from input direcory.
int validateProgramParameters (OppToolContext *oppToolContext)
 Validates and processes commandline parameters.


Define Documentation

#define OPPTOOL_EXIT_ERROR_ALLOC   -2

Definition at line 62 of file opptool.h.

#define OPPTOOL_EXIT_ERROR_BT_CONNECTION   -4

Definition at line 64 of file opptool.h.

#define OPPTOOL_EXIT_ERROR_BT_SESSION   -5

Definition at line 65 of file opptool.h.

#define OPPTOOL_EXIT_ERROR_GENERIC   -1

Definition at line 61 of file opptool.h.

#define OPPTOOL_EXIT_ERROR_INTERNAL_PARAM   -6

Definition at line 66 of file opptool.h.

#define OPPTOOL_EXIT_ERROR_OPTIONS   -3

Definition at line 63 of file opptool.h.

#define OPPTOOL_EXIT_SUCCESS   0

Definition at line 60 of file opptool.h.

#define OPPTOOL_MAX_STD_FILENAME   50

Definition at line 68 of file opptool.h.


Typedef Documentation

typedef struct _Listing Listing

Structure for unicode string listing

typedef struct _OppToolContext OppToolContext

Structure for opptool context, filled in validateProgramParameters function


Enumeration Type Documentation

enum OppToolOperationMode

Structure for unicode string listing

Enumerator:
OPPTOOL_OPERATION_MODE_UNKNOWN 
OPPTOOL_OPERATION_MODE_PULL_FILES 
OPPTOOL_OPERATION_MODE_PULL_ALL 
OPPTOOL_OPERATION_MODE_PULL_STD 
OPPTOOL_OPERATION_MODE_PULL_VCARD 
OPPTOOL_OPERATION_MODE_PUSH_FILES 
OPPTOOL_OPERATION_MODE_PUSH_DIRECTORY 

Definition at line 74 of file opptool.h.


Function Documentation

void appendListing ( Listing list,
wchar_t *  item 
)

append listing

Append new entry to the end of the listing.

Parameters:
list - Pointer to the listing to add the entry
item - Pointer to the string

BOOL authenticationFunction ( LPVOID *  param,
BLUETOOTH_DEVICE_INFO *  bdi 
)

callback function for authenticating remote device

Authentication callback function registered by opptool and called by system when remote device requsts authentication

Parameters:
param - Parameter from opptool given when registering the callback.
bdi - Pointer to the bluetooth device info specifying the device which requests authentication
Remarks:
The param contains the ascii string given to the program in --pin parameter, or NULL if it's not given. The functions calls BluetoothSendAuthenticationResponse to send the authentication response. If pin was NULL uses default pin value of 0000. Debug build asks the pin from user.
Returns:
TRUE if function succeeds and FALSE if not. The system does not use the return value for anything.

void cleanupOppToolContext ( OppToolContext oppToolContext  ) 

Cleanup the opptool context.

Cleanup the context. Closes obex session, closes bluetooth connection, clears listings and frees all memory allocated for context.

Parameters:
oppToolContext - Pointer to the opptool context to be cleared

void clearListing ( Listing list  ) 

clear listing

Remove all entries from the listing.

Parameters:
list - Pointer to the listing to clear

int createFileAndFolderListing ( xmlDoc document,
Listing fileListing,
Listing folderListing 
)

create listing from folder-listing xml document

Creates file and folder listing from xml document

Parameters:
document - Pointer to the xml folder-listing document
fileListing - Pointer to the listing receiving file entries
folderListing - Pointer to the listing receiving folder entries
Remarks:
The xml document contains list of files and folders in parent folder. The xml document do not contain subfolder listing. The files do not contain path.
Returns:
Returns zero if the function fails and non-zero if it succeeds.

int createFileListing ( Listing fileListing,
char *  fileString 
)

list filenames from --files commandline parameter

Creates list of filenames from the opptool --files commandline parameter.

Parameters:
fileListing - Pointer to the listing receiving the filenames
fileString - Pointer to the string containig the files
Remarks:
The filesString must be in the syntax specified by the requirements specifications. "localFile1.txt#remoteFile1.txt;localFile2.txt#remoteFile2.txt;" The listing contains first the local filename and then the remote filename.
Returns:
Returns zero if the function fails and non-zero if it succeeds.

int createFileListingFromDirectory ( Listing fileListing,
wchar_t *  directory,
int *  files,
int *  folders 
)

create listing from local directory

Lists all files and folders from given directory

Parameters:
fileListing - Pointer to the listing to be filled with the files and folders
directory - Null terminating string specifying the directory
files - Pointer to the variable receiving number of files listed
folders - Pointer to the variable receiving number of folders listed
Remarks:
The files are listed without the path. Subfolders are indicated by appending "##directory##" entry to the list and then the name of the folder. The end of the folder is indicated by appending "##end##" entry to the list.
Returns:
Returns zero if the function fails and non-zero if it succeeds.

int createFileListingFromSubDirectory ( Listing fileListing,
wchar_t *  directory,
int *  files,
int *  folders 
)

create listing from local sub directory

Recursive function lists all files and folders from given subdirectory

Parameters:
fileListing - Pointer to the listing to be filled with the files and folders
directory - Null terminating string specifying the directory
files - Pointer to the variable receiving number of files listed
folders - Pointer to the variable receiving number of folders listed
Remarks:
This is the recursive version of the createFileListingFromDirectory. The createFileListingFromDirectory calls this for subfolders.
Returns:
Returns zero if the function fails and non-zero if it succeeds.

int createPathListing ( Listing folderListing,
wchar_t *  path 
)

create list of path folders and filename

Creates list of folders and filename of string that contains full path

Parameters:
folderListing - Pointer to the listing receiving the folders and filename
path - Pointer to the path containing the folders and filename
Remarks:
The path may not contain drive letter. Example: "\path1\path2\filename.txt" -> listing: path1, path2, filename.txt
Returns:
Returns zero if the function fails and non-zero if it succeeds.

BOOL CtrlHandler ( DWORD  fdwCtrlType  ) 

close program when CTRL-C pressed

Parameters:
fdwCtrlType - interrupt, when something pressed from keyboard
Returns:
zero if everything went right

const char* ErrorMessage ( int  error  ) 

Converts integer type return value to corresponding literal error string.

Parameters:
error - Integer error value
Returns:
Pointer to error string

const wchar_t* ErrorMessageW ( int  error  ) 

void printHelp ( void   ) 

Print help text.

This function prints the help text to the screen.

int pullAllFolder ( ObexSession session,
wchar_t *  remoteFolder,
wchar_t *  lastFolder,
wchar_t *  fullRemoteFolder 
)

pulls all files from remote folder

Recursive function for pulling all files from remote device

Parameters:
session - Pointer to the obex session used in the pull operation
remoteFolder - The remote folder name
lastFolder - Parameter containing the full path of the parent folder of remoteFolder
fullRemoteFolder - Full path to the current folder
Remarks:
This is recursive function to pull all files from remote folder. The function calls itself for all subfolders in a remoteFolder
Returns:
ERROR_SUCCESS if functions succeeds.

int pushAllFolder ( OppToolContext oppToolContext  ) 

Push all files from input direcory.

Push all files from the directory specified in the opptool in-dir parameter or from program directory.

Parameters:
oppToolContext - Pointer to the oppToolContext which contains all information for the operation
Remarks:
The files and folders are listed in the context.filesListing parameter which is created when validating opptool parameters
Returns:
Returns zero if the function fails and non-zero if it succeeds.

int validateProgramParameters ( OppToolContext oppToolContext  ) 

Validates and processes commandline parameters.

Validates commandline parameters. Checks for conflicts and required parameters. Processes --files parameter and creates listing from --in-dir parameter. Registers authentication callback. Chooses service for connection.

Parameters:
oppToolContext - Pointer to the opptool context which contains the commandline parameters and receives the processed parameters.
Remarks:
The commandline parameters must have been parsed using parseOpts.
Returns:
OPPTOOL_EXIT_ERROR_GENERIC if oppToolContext parameter is NULL.

OPPTOOL_EXIT_ERROR_OPTIONS if commandline parameters are incorrect or processng the parameters fails.

footer


 SourceForge.net Logo