~snaggen/rhythmbox/bpm

« back to all changes in this revision

Viewing changes to plugins/mtpdevice/rb-mtp-plugin.c

  • Committer: James Livingston
  • Author(s): James Livingston
  • Date: 2007-11-25 07:24:57 UTC
  • Revision ID: git-v1:b15d7482ba708af8778d80e83ec24fc7eb5c503b
fix some memory leaks. patch partially by John Daiker.

2007-11-25  James Livingston  <doclivingston@gmail.com>

        * bindings/python/rb.defs:
        * metadata/rb-metadata-dbus-service.c: (main):
        * plugins/rb-plugins-engine.c: (rb_plugins_engine_load),
        (rb_plugins_engine_load_cb):
        * plugins/sample-vala/rb-sample-vala-plugin.vala:
        * plugins/visualizer/rb-visualizer-plugin.c: (get_vis_plugin_list):
        * shell/rb-shell.c: (rb_shell_finalize), (construct_widgets):
        * shell/rb-tray-icon.c: (rb_tray_icon_init):
        * tools/massif.sh:
        * widgets/rb-entry-view.c: (rb_entry_view_get_sorting_type):
        * widgets/rb-entry-view.h: fix some memory leaks. patch partially by
        John Daiker.

svn path=/trunk/; revision=5456

Show diffs side-by-side

added added

removed removed

Lines of Context:
96
96
 
97
97
static GtkActionEntry rb_mtp_plugin_actions [] =
98
98
{
99
 
        { "RemovableSourceEject", GNOME_MEDIA_EJECT, N_("_Eject"), NULL,
 
99
        { "MTPSourceEject", GNOME_MEDIA_EJECT, N_("_Eject"), NULL,
100
100
          N_("Eject MTP-device"),
101
101
          G_CALLBACK (rb_mtp_plugin_eject) },
102
102
        { "MTPSourceRename", NULL, N_("_Rename"), NULL,
166
166
 
167
167
        rb_mtp_plugin_setup_dbus_hal_connection (plugin);
168
168
 
 
169
        rb_profile_start ("scanning for MTP devices");
169
170
        devices = libhal_get_all_devices (plugin->hal_context, &num, NULL);
170
171
        ret = LIBMTP_Get_Supported_Devices_List (&entries, &numentries);
171
172
        if (ret == 0) {
172
 
                int  p;
173
 
 
174
 
                for (p = 0; p < numentries; p++) {
175
 
                        for (i = 0; i < num; i++) {
176
 
                                int vendor_id;
177
 
                                int product_id;
178
 
                                const char *tmpudi;
179
 
 
180
 
                                tmpudi = devices[i];
181
 
                                vendor_id = libhal_device_get_property_int (plugin->hal_context, tmpudi, "usb.vendor_id", NULL);
182
 
                                product_id = libhal_device_get_property_int (plugin->hal_context, tmpudi, "usb.product_id", NULL);
 
173
 
 
174
                for (i = 0; i < num; i++) {
 
175
                        int vendor_id;
 
176
                        int product_id;
 
177
                        const char *tmpudi;
 
178
                        int  p;
 
179
 
 
180
                        tmpudi = devices[i];
 
181
                        vendor_id = libhal_device_get_property_int (plugin->hal_context, tmpudi, "usb.vendor_id", NULL);
 
182
                        product_id = libhal_device_get_property_int (plugin->hal_context, tmpudi, "usb.product_id", NULL);
 
183
                        for (p = 0; p < numentries; p++) {
183
184
 
184
185
                                if (entries[p].vendor_id == vendor_id && entries[p].product_id == product_id) {
185
186
                                        LIBMTP_mtpdevice_t *device = LIBMTP_Get_First_Device ();
186
187
                                        if (device != NULL) {
187
188
                                                create_source_cb (plugin, device, tmpudi);
 
189
                                                break;
188
190
                                        } else {
189
191
                                                rb_debug ("error, could not get a hold on the device. Reset and Restart");
190
192
                                        }
195
197
                rb_debug ("Couldn't list mtp devices");
196
198
        }
197
199
        libhal_free_string_array (devices);
 
200
        rb_profile_end ("scanning for MTP devices");
198
201
 
199
202
        g_object_unref (G_OBJECT (uimanager));
200
203
}
326
329
                                /*
327
330
                                 * FIXME:
328
331
                                 *
329
 
                                 * It usualy takes a while for the device o set itself up.
 
332
                                 * It usualy takes a while for the device to set itself up.
330
333
                                 * Solving that by trying 10 times with some sleep in between.
331
334
                                 * There is probably a better solution, but this works.
332
335
                                 */
340
343
                                        usleep (200000);
341
344
                                }
342
345
                        }
 
346
                }
343
347
        }
344
 
    }
345
348
}
346
349
 
347
350
static void