
int main(int argc, char* argv[])
{
signal(SIGINT, Exit);
if (InitShareKit(NULL) != 0) {
goto done;
}
ShareRecvHandle recvHandler;
memset(&recvHandler, 0, sizeof(ShareRecvHandle));
recvHandler.statusCb = SharekitStatusChangeCbFunc;
recvHandler.previewCb = RequestFileTrans;
recvHandler.finishCb = FileTransferResult;
if (StartShareService(RECEIVER, &recvHandler) != 0) {
goto done;
}
StopShareService();
UninitShareKit();
sleep(1);
printf("main exit. \n");
return 0;
} Starts the request for initializing device resources for Share Engine.
Function Declaration | int InitShare Kit(void* handle) | ||
|---|---|---|---|
Parameter | void* | handle |
|
Return Value | int | 0: success; other values: failure | |
Notify the user of the preview of files to receive by Share Engine.
Function Declaration | typedef void (*ShareFilePreviewCallback)(const char** fileNames, int fileNum) | ||
|---|---|---|---|
Parameter | const char** | fileNames | List of files to receive |
Parameter | int | fileNum | Number of the files to receive |
Return Value | void | NA | |
Notify the user of the file transfer result (success or failure).
Function Declaration | typedef void (*ShareFileFinishCallback)(int result, const char** failedFileNames, int failedFileNum) | ||
|---|---|---|---|
Parameter | int | result | File transfer result. The value 0 indicates success, and other values indicate failure. |
Parameter | const char** | failedFileNames | List of the files that fail to be received. |
Parameter | int | failedFileNum | Number of the files that fail to be received. |
Return Value | void | N/A | |
Instruct Share Engine to receive files and store them to the specified path, after the user chooses to accept the file transfer request.
Function Declaration | int ConfirmFileRecv(char *path) | ||
|---|---|---|---|
Parameter | char * | path | File storage path |
Return Value | int | 0: success; other values: failure | |
Call this API to send a reject notification after the user chooses to reject the file transfer request.
Function Declaration | void RefuseRecvFile(void) | |
|---|---|---|
Return Value | void | N/A |
Release the system resources occupied by Share Engine.
Function Declaration | int UninitShare Kit(void) | |
|---|---|---|
Return Value | int | 0: success; other values: failure |
For details about the APIs, please refer to the API Reference.
For details about the code example, please refer to the Sample Code.