Mercurial > audlegacy-plugins
annotate src/mtp_up/mtp.c @ 1517:d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
| author | Cristi Magherusan <majeru@atheme-project.org> |
|---|---|
| date | Thu, 23 Aug 2007 16:47:45 +0300 |
| parents | 611d8db6b421 |
| children | abdb27a70322 |
| rev | line source |
|---|---|
|
1456
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
1 /* |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
2 * Audacious MTP upload plugin |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
3 * |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
4 * Copyright (c) 2007 Cristian Magherusan <majeru@atheme.org> |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
5 * |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
6 * This program is free software; you can redistribute it and/or modify |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
7 * it under the terms of the GNU General Public License as published by |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
8 * the Free Software Foundation; under version 3 of the License. |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
9 * |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
10 * This program is distributed in the hope that it will be useful, |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
13 * GNU General Public License for more details. |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
14 * |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
16 * along with this program. If not, see <http://www.gnu.org/licenses>. |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
17 */ |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
18 |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
19 #include <glib.h> |
|
1517
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
20 #include <sys/types.h> |
|
1456
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
21 #include <libmtp.h> |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
22 #include <audacious/plugin.h> |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
23 #include <audacious/playlist.h> |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
24 #include <audacious/ui_plugin_menu.h> |
|
1500
611d8db6b421
made it enabled by default if having libmtp, fixes Chainsaw's bug and adds some improvements
Cristi Magherusan <majeru@atheme-project.org>
parents:
1497
diff
changeset
|
25 |
|
611d8db6b421
made it enabled by default if having libmtp, fixes Chainsaw's bug and adds some improvements
Cristi Magherusan <majeru@atheme-project.org>
parents:
1497
diff
changeset
|
26 #include <gtk/gtk.h> |
|
611d8db6b421
made it enabled by default if having libmtp, fixes Chainsaw's bug and adds some improvements
Cristi Magherusan <majeru@atheme-project.org>
parents:
1497
diff
changeset
|
27 #include <audacious/util.h> |
|
1517
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
28 #include "filetype.h" |
|
1456
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
29 #define DEBUG 1 |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
30 |
|
1517
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
31 #define ROOT_LABEL "MTP device handler" |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
32 #define UP_DEFAULT_LABEL "Upload selected track(s)" |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
33 #define UP_BUSY_LABEL "Upload in progress..." |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
34 #define FREE_LABEL "Disconnect the device" |
|
1456
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
35 GMutex * mutex = NULL; |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
36 gboolean mtp_initialised = FALSE; |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
37 LIBMTP_mtpdevice_t *mtp_device = NULL; |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
38 LIBMTP_progressfunc_t *callback; |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
39 LIBMTP_file_t *filelist; |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
40 Playlist *active_playlist; |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
41 |
|
1500
611d8db6b421
made it enabled by default if having libmtp, fixes Chainsaw's bug and adds some improvements
Cristi Magherusan <majeru@atheme-project.org>
parents:
1497
diff
changeset
|
42 static gboolean plugin_active = FALSE,exiting=FALSE; |
|
1461
161d289f335c
do not assume that mtp_cleanup is only called after mtp_init (it's not true for general plugins); also, destroy the menuitem as it seems that it still holds a reference after being removed from its menushell
Giacomo Lozito <james@develia.org>
parents:
1458
diff
changeset
|
43 |
|
1456
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
44 void mtp_init ( void ); |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
45 void mtp_cleanup ( void ); |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
46 void mtp_prefs ( void ); |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
47 void mtp_about ( void ); |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
48 |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
49 GeneralPlugin mtp_gp = |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
50 { |
|
1468
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
51 NULL, /* handle */ |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
52 NULL, /* filename */ |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
53 "MTP Upload " , /* description */ |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
54 mtp_init, /* init */ |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
55 mtp_about, /* about */ |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
56 mtp_prefs, /* configure */ |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
57 mtp_cleanup /* cleanup */ |
|
1456
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
58 }; |
|
1517
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
59 GtkWidget *mtp_root_menuitem,*mtp_submenu_item_up,*mtp_submenu_item_free,*mtp_submenu; |
|
1456
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
60 |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
61 GeneralPlugin *mtp_gplist[] = { &mtp_gp, NULL }; |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
62 DECLARE_PLUGIN(mtp_gp, NULL, NULL, NULL, NULL, NULL, mtp_gplist, NULL, NULL) |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
63 |
|
1497
318e3bcdf51d
some fixes, more debug info
Cristi Magherusan <majeru@atheme-project.org>
parents:
1495
diff
changeset
|
64 |
|
1500
611d8db6b421
made it enabled by default if having libmtp, fixes Chainsaw's bug and adds some improvements
Cristi Magherusan <majeru@atheme-project.org>
parents:
1497
diff
changeset
|
65 void show_dialog(const gchar* message) |
|
1497
318e3bcdf51d
some fixes, more debug info
Cristi Magherusan <majeru@atheme-project.org>
parents:
1495
diff
changeset
|
66 { |
|
1500
611d8db6b421
made it enabled by default if having libmtp, fixes Chainsaw's bug and adds some improvements
Cristi Magherusan <majeru@atheme-project.org>
parents:
1497
diff
changeset
|
67 GDK_THREADS_ENTER(); |
|
611d8db6b421
made it enabled by default if having libmtp, fixes Chainsaw's bug and adds some improvements
Cristi Magherusan <majeru@atheme-project.org>
parents:
1497
diff
changeset
|
68 GtkWidget *dialog = gtk_message_dialog_new (NULL, |
|
611d8db6b421
made it enabled by default if having libmtp, fixes Chainsaw's bug and adds some improvements
Cristi Magherusan <majeru@atheme-project.org>
parents:
1497
diff
changeset
|
69 GTK_DIALOG_MODAL, |
|
1497
318e3bcdf51d
some fixes, more debug info
Cristi Magherusan <majeru@atheme-project.org>
parents:
1495
diff
changeset
|
70 GTK_MESSAGE_ERROR, |
|
318e3bcdf51d
some fixes, more debug info
Cristi Magherusan <majeru@atheme-project.org>
parents:
1495
diff
changeset
|
71 GTK_BUTTONS_OK, |
|
318e3bcdf51d
some fixes, more debug info
Cristi Magherusan <majeru@atheme-project.org>
parents:
1495
diff
changeset
|
72 message); |
|
318e3bcdf51d
some fixes, more debug info
Cristi Magherusan <majeru@atheme-project.org>
parents:
1495
diff
changeset
|
73 gtk_dialog_run (GTK_DIALOG (dialog)); |
|
1500
611d8db6b421
made it enabled by default if having libmtp, fixes Chainsaw's bug and adds some improvements
Cristi Magherusan <majeru@atheme-project.org>
parents:
1497
diff
changeset
|
74 gtk_widget_show(dialog); |
|
611d8db6b421
made it enabled by default if having libmtp, fixes Chainsaw's bug and adds some improvements
Cristi Magherusan <majeru@atheme-project.org>
parents:
1497
diff
changeset
|
75 gtk_widget_destroy(dialog); |
|
611d8db6b421
made it enabled by default if having libmtp, fixes Chainsaw's bug and adds some improvements
Cristi Magherusan <majeru@atheme-project.org>
parents:
1497
diff
changeset
|
76 GDK_THREADS_LEAVE(); |
|
611d8db6b421
made it enabled by default if having libmtp, fixes Chainsaw's bug and adds some improvements
Cristi Magherusan <majeru@atheme-project.org>
parents:
1497
diff
changeset
|
77 |
|
1497
318e3bcdf51d
some fixes, more debug info
Cristi Magherusan <majeru@atheme-project.org>
parents:
1495
diff
changeset
|
78 } |
|
318e3bcdf51d
some fixes, more debug info
Cristi Magherusan <majeru@atheme-project.org>
parents:
1495
diff
changeset
|
79 |
|
1517
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
80 void free_device() |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
81 { |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
82 #if DEBUG |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
83 if(mtp_initialised) |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
84 g_print("\n\n !!!CAUTION!!! \n\n" |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
85 "Cleaning up MTP upload plugin, please wait!!!...\n" |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
86 "This will block until the pending tracks are uploaded,\n" |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
87 "then it will gracefully close your device\n\n" |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
88 "!!! FORCING SHUTDOWN NOW MAY CAUSE DAMAGE TO YOUR DEVICE !!!\n\n\n" |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
89 "Waiting for the MTP mutex to unlock...\n"); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
90 #endif |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
91 if(!mutex) |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
92 return; |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
93 g_mutex_lock(mutex); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
94 if(mtp_device!= NULL) |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
95 { |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
96 LIBMTP_Release_Device(mtp_device); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
97 mtp_device = NULL; |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
98 mtp_initialised = FALSE; |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
99 gtk_widget_hide(mtp_submenu_item_free); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
100 } |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
101 g_mutex_unlock(mutex); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
102 return; |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
103 } |
|
1497
318e3bcdf51d
some fixes, more debug info
Cristi Magherusan <majeru@atheme-project.org>
parents:
1495
diff
changeset
|
104 |
|
1468
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
105 GList * get_upload_list() |
|
1456
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
106 { |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
107 Tuple *tuple; |
|
1468
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
108 GList *node=NULL,*up_list=NULL; |
|
1456
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
109 PlaylistEntry *entry; |
|
1468
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
110 Playlist *current_play = playlist_get_active(); |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
111 |
|
1456
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
112 node = current_play->entries; |
|
1468
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
113 PLAYLIST_LOCK(current_play->mutex); /*needed so that the user doesn't modify the selection*/ |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
114 while (node) /*while creating the list of files to be uploaded*/ |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
115 { |
|
1456
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
116 entry = PLAYLIST_ENTRY(node->data); |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
117 if (entry->selected) |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
118 { |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
119 tuple = entry->tuple; |
|
1517
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
120 up_list=g_list_prepend(up_list,tuple); |
|
1456
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
121 entry->selected = FALSE; |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
122 } |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
123 node = g_list_next(node); |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
124 } |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
125 PLAYLIST_UNLOCK(current_play->mutex); |
|
1468
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
126 return g_list_reverse(up_list); |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
127 } |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
128 |
|
1517
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
129 LIBMTP_track_t *track_metadata(Tuple *from_tuple) |
|
1468
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
130 { |
|
1517
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
131 LIBMTP_track_t *tr; |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
132 gchar *from_path,*filename; |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
133 VFSFile *f; |
|
1468
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
134 uint64_t filesize; |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
135 uint32_t parent_id = 0; |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
136 struct stat sb; |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
137 |
|
1517
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
138 from_path = g_strdup_printf("%s/%s", tuple_get_string(from_tuple, "file-path"), tuple_get_string(from_tuple, "file-name")); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
139 gchar *tmp; |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
140 tmp = g_strescape(from_path,NULL); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
141 filename=g_filename_from_uri(tmp,NULL,NULL); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
142 /* dealing the stream uploa (invalidating)*/ |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
143 if(filename) |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
144 { |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
145 f = vfs_fopen(from_path,"r"); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
146 if(vfs_is_streaming(f)) |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
147 { |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
148 vfs_fclose(f); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
149 return NULL; |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
150 } |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
151 } |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
152 |
|
1468
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
153 if ( stat(from_path, &sb) == -1 ) |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
154 { |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
155 #if DEBUG |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
156 g_print("ERROR! encountered while stat()'ing \"%s\"\n",from_path); |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
157 #endif |
|
1517
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
158 return NULL; |
|
1468
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
159 } |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
160 filesize = (uint64_t) sb.st_size; |
|
1500
611d8db6b421
made it enabled by default if having libmtp, fixes Chainsaw's bug and adds some improvements
Cristi Magherusan <majeru@atheme-project.org>
parents:
1497
diff
changeset
|
161 parent_id = mtp_device->default_music_folder; |
|
1517
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
162 |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
163 /* track metadata*/ |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
164 tr = LIBMTP_new_track_t(); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
165 tr->title =(gchar*) tuple_get_string(from_tuple, "title"); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
166 tr->artist =(gchar*) tuple_get_string(from_tuple,"artist"); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
167 tr->album = (gchar*)tuple_get_string(from_tuple,"album"); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
168 tr->filesize = filesize; |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
169 tr->filename = strdup(from_path); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
170 tr->duration = (uint32_t)tuple_get_int(from_tuple, "length"); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
171 tr->filetype = find_filetype (from_path); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
172 tr->genre = (gchar*)tuple_get_string(from_tuple, "genre"); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
173 tr->date = g_strdup_printf("%d",tuple_get_int(from_tuple, "year")); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
174 |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
175 g_free(filename); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
176 g_free(from_path); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
177 g_free(tmp); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
178 return tr; |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
179 } |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
180 |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
181 gint upload_file(Tuple *from_tuple) |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
182 { |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
183 int ret; |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
184 gchar *comp; |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
185 uint32_t parent_id = 0; |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
186 LIBMTP_track_t *gentrack; |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
187 |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
188 gentrack = track_metadata(from_tuple); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
189 if(gentrack == NULL) return 1; |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
190 |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
191 comp = g_strescape(gentrack->filename,NULL); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
192 parent_id = mtp_device->default_music_folder; |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
193 |
|
1468
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
194 #if DEBUG |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
195 g_print("Uploading track '%s'\n",comp); |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
196 #endif |
|
1517
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
197 ret = LIBMTP_Send_Track_From_File(mtp_device, comp , gentrack, NULL , NULL, parent_id); |
|
1468
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
198 if (ret == 0) |
|
1517
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
199 g_print("Track upload finished!\n"); |
|
1468
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
200 else |
|
1494
63144ea14b50
handling device disconnected errors
Cristi Magherusan <majeru@atheme-project.org>
parents:
1491
diff
changeset
|
201 { |
|
1468
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
202 g_print("An error has occured while uploading '%s'...\nUpload failed!!!",comp); |
|
1494
63144ea14b50
handling device disconnected errors
Cristi Magherusan <majeru@atheme-project.org>
parents:
1491
diff
changeset
|
203 mtp_initialised = FALSE; |
|
1500
611d8db6b421
made it enabled by default if having libmtp, fixes Chainsaw's bug and adds some improvements
Cristi Magherusan <majeru@atheme-project.org>
parents:
1497
diff
changeset
|
204 return 1; |
|
1494
63144ea14b50
handling device disconnected errors
Cristi Magherusan <majeru@atheme-project.org>
parents:
1491
diff
changeset
|
205 } |
|
1517
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
206 |
|
1500
611d8db6b421
made it enabled by default if having libmtp, fixes Chainsaw's bug and adds some improvements
Cristi Magherusan <majeru@atheme-project.org>
parents:
1497
diff
changeset
|
207 return 0; |
|
1468
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
208 } |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
209 |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
210 |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
211 gpointer upload(gpointer arg) |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
212 { |
|
1517
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
213 gtk_widget_hide(mtp_submenu_item_free); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
214 if(!mutex) |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
215 { |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
216 gtk_widget_hide(mtp_submenu_item_up); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
217 gtk_label_set_text(GTK_LABEL(gtk_bin_get_child(GTK_BIN(mtp_submenu_item_up))),UP_DEFAULT_LABEL); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
218 gtk_widget_set_sensitive(mtp_submenu_item_up, TRUE); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
219 gtk_widget_show(mtp_submenu_item_up); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
220 return NULL; |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
221 } |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
222 g_mutex_lock(mutex); |
|
1468
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
223 if(!mtp_device) |
|
1517
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
224 { |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
225 gtk_widget_hide(mtp_submenu_item_up); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
226 gtk_label_set_text(GTK_LABEL(gtk_bin_get_child(GTK_BIN(mtp_submenu_item_up))),UP_DEFAULT_LABEL); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
227 gtk_widget_set_sensitive(mtp_submenu_item_up, TRUE); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
228 g_mutex_unlock(mutex); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
229 gtk_widget_show(mtp_submenu_item_up); |
|
1494
63144ea14b50
handling device disconnected errors
Cristi Magherusan <majeru@atheme-project.org>
parents:
1491
diff
changeset
|
230 return NULL; |
|
63144ea14b50
handling device disconnected errors
Cristi Magherusan <majeru@atheme-project.org>
parents:
1491
diff
changeset
|
231 } |
|
1474
10791910b866
the label wasn't restored on failure
Cristi Magherusan <majeru@atheme-project.org>
parents:
1471
diff
changeset
|
232 |
|
1517
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
233 Tuple* tuple; |
|
1468
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
234 GList *up_list=NULL,*node; |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
235 node=up_list=get_upload_list(); |
|
1500
611d8db6b421
made it enabled by default if having libmtp, fixes Chainsaw's bug and adds some improvements
Cristi Magherusan <majeru@atheme-project.org>
parents:
1497
diff
changeset
|
236 gint up_err=0; |
|
1468
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
237 while(node) |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
238 { |
|
1517
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
239 tuple=(Tuple*)(node->data); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
240 up_err = upload_file(tuple); |
|
1500
611d8db6b421
made it enabled by default if having libmtp, fixes Chainsaw's bug and adds some improvements
Cristi Magherusan <majeru@atheme-project.org>
parents:
1497
diff
changeset
|
241 if(up_err ) |
|
1517
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
242 { |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
243 show_dialog("An error has occured while uploading...\nUpload failed!"); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
244 break; |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
245 } |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
246 if(exiting) |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
247 { |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
248 /*show_dialog("Shutting down MTP while uploading.\nPending uploads were cancelled");*/ |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
249 break; |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
250 } |
|
1500
611d8db6b421
made it enabled by default if having libmtp, fixes Chainsaw's bug and adds some improvements
Cristi Magherusan <majeru@atheme-project.org>
parents:
1497
diff
changeset
|
251 |
|
1468
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
252 node = g_list_next(node); |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
253 } |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
254 g_list_free(up_list); |
|
1517
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
255 gtk_widget_hide(mtp_submenu_item_up); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
256 gtk_label_set_text(GTK_LABEL(gtk_bin_get_child(GTK_BIN(mtp_submenu_item_up))),UP_DEFAULT_LABEL); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
257 gtk_widget_set_sensitive(mtp_submenu_item_up, TRUE); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
258 gtk_widget_show(mtp_submenu_item_up); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
259 g_mutex_unlock(mutex); |
|
1497
318e3bcdf51d
some fixes, more debug info
Cristi Magherusan <majeru@atheme-project.org>
parents:
1495
diff
changeset
|
260 #if DEBUG |
|
1517
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
261 g_print("MTP upload process finished\n"); |
|
1497
318e3bcdf51d
some fixes, more debug info
Cristi Magherusan <majeru@atheme-project.org>
parents:
1495
diff
changeset
|
262 #endif |
|
1517
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
263 gtk_widget_show(mtp_submenu_item_free); |
|
1497
318e3bcdf51d
some fixes, more debug info
Cristi Magherusan <majeru@atheme-project.org>
parents:
1495
diff
changeset
|
264 g_thread_exit(NULL); |
|
1456
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
265 return NULL; |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
266 } |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
267 |
|
1474
10791910b866
the label wasn't restored on failure
Cristi Magherusan <majeru@atheme-project.org>
parents:
1471
diff
changeset
|
268 void mtp_prefs ( void ) |
|
1456
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
269 { |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
270 /*pref stub*/ |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
271 } |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
272 |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
273 |
|
1474
10791910b866
the label wasn't restored on failure
Cristi Magherusan <majeru@atheme-project.org>
parents:
1471
diff
changeset
|
274 void mtp_about ( void ) |
|
1456
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
275 { |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
276 /*about stub*/ |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
277 } |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
278 |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
279 void mtp_press() |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
280 { |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
281 if(!mutex) |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
282 return; |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
283 g_mutex_lock(mutex); |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
284 if(!mtp_initialised) |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
285 { |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
286 #if DEBUG |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
287 g_print("Initializing the MTP device...\n"); |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
288 #endif |
|
1468
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
289 LIBMTP_Init(); |
|
1456
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
290 mtp_device = LIBMTP_Get_First_Device(); |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
291 mtp_initialised = TRUE; |
|
1517
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
292 gtk_widget_show(mtp_submenu_item_free); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
293 |
|
1456
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
294 } |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
295 g_mutex_unlock(mutex); |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
296 if(mtp_device == NULL) |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
297 { |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
298 #if DEBUG |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
299 g_print("No MTP devices have been found !!!"); |
|
1497
318e3bcdf51d
some fixes, more debug info
Cristi Magherusan <majeru@atheme-project.org>
parents:
1495
diff
changeset
|
300 #endif |
|
318e3bcdf51d
some fixes, more debug info
Cristi Magherusan <majeru@atheme-project.org>
parents:
1495
diff
changeset
|
301 show_dialog("No MTP devices have been found !!!"); |
|
318e3bcdf51d
some fixes, more debug info
Cristi Magherusan <majeru@atheme-project.org>
parents:
1495
diff
changeset
|
302 mtp_initialised = FALSE; |
|
1456
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
303 return; |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
304 |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
305 } |
|
1517
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
306 gtk_label_set_text(GTK_LABEL(gtk_bin_get_child(GTK_BIN(mtp_submenu_item_up))),UP_BUSY_LABEL); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
307 gtk_widget_set_sensitive(mtp_submenu_item_up, FALSE); |
|
1497
318e3bcdf51d
some fixes, more debug info
Cristi Magherusan <majeru@atheme-project.org>
parents:
1495
diff
changeset
|
308 g_thread_create(upload,NULL,FALSE,NULL); |
|
318e3bcdf51d
some fixes, more debug info
Cristi Magherusan <majeru@atheme-project.org>
parents:
1495
diff
changeset
|
309 return; |
|
318e3bcdf51d
some fixes, more debug info
Cristi Magherusan <majeru@atheme-project.org>
parents:
1495
diff
changeset
|
310 |
|
1456
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
311 } |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
312 |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
313 void mtp_init(void) |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
314 { |
|
1517
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
315 mtp_root_menuitem=gtk_menu_item_new_with_label(ROOT_LABEL); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
316 mtp_submenu=gtk_menu_new(); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
317 |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
318 mtp_submenu_item_up=gtk_menu_item_new_with_label(UP_DEFAULT_LABEL); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
319 mtp_submenu_item_free=gtk_menu_item_new_with_label(FREE_LABEL); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
320 |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
321 |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
322 gtk_menu_shell_append (GTK_MENU_SHELL (mtp_submenu), mtp_submenu_item_up); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
323 gtk_widget_show (mtp_submenu_item_up); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
324 |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
325 gtk_menu_shell_append (GTK_MENU_SHELL (mtp_submenu), mtp_submenu_item_free); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
326 |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
327 gtk_menu_item_set_submenu(GTK_MENU_ITEM(mtp_root_menuitem),mtp_submenu); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
328 gtk_widget_show (mtp_submenu); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
329 gtk_widget_show (mtp_root_menuitem); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
330 |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
331 |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
332 audacious_menu_plugin_item_add(AUDACIOUS_MENU_PLAYLIST_RCLICK, mtp_root_menuitem); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
333 g_signal_connect (G_OBJECT (mtp_submenu_item_up), "button_press_event",G_CALLBACK (mtp_press), NULL); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
334 g_signal_connect (G_OBJECT (mtp_submenu_item_free), "button_press_event",G_CALLBACK (free_device), NULL); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
335 |
|
1456
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
336 mutex = g_mutex_new(); |
|
1461
161d289f335c
do not assume that mtp_cleanup is only called after mtp_init (it's not true for general plugins); also, destroy the menuitem as it seems that it still holds a reference after being removed from its menushell
Giacomo Lozito <james@develia.org>
parents:
1458
diff
changeset
|
337 plugin_active = TRUE; |
|
1500
611d8db6b421
made it enabled by default if having libmtp, fixes Chainsaw's bug and adds some improvements
Cristi Magherusan <majeru@atheme-project.org>
parents:
1497
diff
changeset
|
338 exiting=FALSE; |
|
1456
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
339 } |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
340 |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
341 void mtp_cleanup(void) |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
342 { |
|
1461
161d289f335c
do not assume that mtp_cleanup is only called after mtp_init (it's not true for general plugins); also, destroy the menuitem as it seems that it still holds a reference after being removed from its menushell
Giacomo Lozito <james@develia.org>
parents:
1458
diff
changeset
|
343 if (plugin_active) |
|
161d289f335c
do not assume that mtp_cleanup is only called after mtp_init (it's not true for general plugins); also, destroy the menuitem as it seems that it still holds a reference after being removed from its menushell
Giacomo Lozito <james@develia.org>
parents:
1458
diff
changeset
|
344 { |
|
1468
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
345 |
|
1456
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
346 #if DEBUG |
|
1468
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
347 if(mtp_initialised) |
|
1517
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
348 { |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
349 g_print("\n\n !!!CAUTION!!! \n\n" |
|
1468
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
350 "Cleaning up MTP upload plugin, please wait!!!...\n" |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
351 "This will block until the pending tracks are uploaded,\n" |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
352 "then it will gracefully close your device\n\n" |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
353 "!!! FORCING SHUTDOWN NOW MAY CAUSE DAMAGE TO YOUR DEVICE !!!\n\n\n" |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
354 "Waiting for the MTP mutex to unlock...\n"); |
|
1517
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
355 exiting=TRUE; |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
356 } |
|
1468
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
357 #endif |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
358 if(mutex) |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
359 g_mutex_lock(mutex); |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
360 if(mtp_device!= NULL) |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
361 { |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
362 LIBMTP_Release_Device(mtp_device); |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
363 mtp_device = NULL; |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
364 } |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
365 g_mutex_unlock(mutex); |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
366 #if DEBUG |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
367 if(mtp_initialised) |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
368 g_print("The MTP mutex has been unlocked\n"); |
|
1456
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
369 #endif |
|
1517
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
370 audacious_menu_plugin_item_remove(AUDACIOUS_MENU_PLAYLIST_RCLICK, mtp_root_menuitem); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
371 gtk_widget_destroy(mtp_submenu_item_up); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
372 |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
373 gtk_widget_destroy(mtp_submenu_item_up); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
374 gtk_widget_destroy(mtp_submenu_item_free); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
375 |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
376 gtk_widget_destroy(mtp_submenu); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
377 |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
378 gtk_widget_destroy(mtp_root_menuitem); |
|
d72a44fdb6a3
switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1500
diff
changeset
|
379 |
|
1461
161d289f335c
do not assume that mtp_cleanup is only called after mtp_init (it's not true for general plugins); also, destroy the menuitem as it seems that it still holds a reference after being removed from its menushell
Giacomo Lozito <james@develia.org>
parents:
1458
diff
changeset
|
380 g_mutex_free (mutex); |
|
161d289f335c
do not assume that mtp_cleanup is only called after mtp_init (it's not true for general plugins); also, destroy the menuitem as it seems that it still holds a reference after being removed from its menushell
Giacomo Lozito <james@develia.org>
parents:
1458
diff
changeset
|
381 mutex = NULL; |
|
161d289f335c
do not assume that mtp_cleanup is only called after mtp_init (it's not true for general plugins); also, destroy the menuitem as it seems that it still holds a reference after being removed from its menushell
Giacomo Lozito <james@develia.org>
parents:
1458
diff
changeset
|
382 plugin_active = FALSE; |
|
1468
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
383 #if DEBUG |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
384 if(mtp_initialised) |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
385 g_print("MTP upload plugin has been cleaned up successfully\n"); |
|
159186076d9a
lots of fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1461
diff
changeset
|
386 #endif |
|
1461
161d289f335c
do not assume that mtp_cleanup is only called after mtp_init (it's not true for general plugins); also, destroy the menuitem as it seems that it still holds a reference after being removed from its menushell
Giacomo Lozito <james@develia.org>
parents:
1458
diff
changeset
|
387 } |
|
1456
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
388 } |
|
475eac76a8ba
MTP upload plugin
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
389 |
