Initial commit (based on data-sharing-plugin)
[sharing-cli] / src / .svn / text-base / send.c.svn-base
1 /*
2  * This file is part of sharing-plugin-template
3  *
4  * Copyright (C) 2008-2009 Nokia Corporation. All rights reserved.
5  *
6  * This maemo code example is licensed under a MIT-style license,
7  * that can be found in the file called "COPYING" in the root
8  * directory.
9  *
10  */
11
12 #include <stdio.h>
13 #include <glib.h>
14 #include <osso-log.h>
15 #include <sharing-http.h>
16 #include "send.h"
17 #include "common.h"
18
19 /**
20  * send:
21  * @account: #SharingTransfer to be send
22  * @con: Connection used
23  * @dead_mans_switch: Turn to %FALSE at least every 30 seconds.
24  *
25  * Sends #SharingTransfer to service.
26  *
27  * Returns: #SharingPluginInterfaceSendResult
28  */
29 SharingPluginInterfaceSendResult send (SharingTransfer* transfer,
30     ConIcConnection* con, gboolean* dead_mans_switch)
31 {
32     SharingPluginInterfaceSendResult ret = SHARING_SEND_SUCCESS;
33
34     SharingEntry *entry = sharing_transfer_get_entry( transfer );
35
36     gint result = 0;
37
38     for (GSList* p = sharing_entry_get_media (entry); p != NULL; p = g_slist_next(p)) {
39       SharingEntryMedia* media = p->data;
40       /* Process media */
41       if (!sharing_entry_media_get_sent (media)) {
42         /* Post media */
43         //result = my_send_task_post_function (my_send_task, media);
44         /* Process post result */
45         if (result == 0 /* EXAMPLE: MY_SEND_RESULT_SUCCESS */) {
46           /* If success mark media as sent */
47           sharing_entry_media_set_sent (media, TRUE);
48           /* And mark process to your internal data structure */
49           //my_send_task->upload_done += sharing_entry_media_get_size (media); 
50         } else {
51           /* We have sent the file in last sharing-manager call */
52           //my_send_task->upload_done += sharing_entry_media_get_size (media);
53         }
54       }
55     }
56
57     return ret;
58 }
59