~ubuntu-branches/ubuntu/oneiric/gecko-mediaplayer/oneiric

« back to all changes in this revision

Viewing changes to src/plugin_setup.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Cesare Tirabassi
  • Date: 2010-02-17 10:17:01 UTC
  • mfrom: (1.1.15 upstream)
  • Revision ID: james.westby@ubuntu.com-20100217101701-mqfz0z0owm89ut9y
Tags: 0.9.9.1~svn374-0ubuntu1
* SVN snapshot release (LP: #86777, LP: #445767, Closes: #557761):
  - apple.com fixes
* Replace Build-Depends on iceape-dev with xulrunner-dev (Closes: #555916)
* No change bump of Standards-Version
* Converted to source format 3.0
* Add opera (>= 9.50) as a compatible browser (LP: #230662)
* Remove linker flag -z defs since the plugin doesn't link to all
  required libraries on purpose

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
#include "plugin_setup.h"
41
41
 
42
42
// void new_instance(CPlugin * instance, nsPluginCreateData * parameters)
43
 
void new_instance(CPlugin * instance, int16 argc, char *argn[], char *argv[])
 
43
void new_instance(CPlugin * instance, int16_t argc, char *argn[], char *argv[])
44
44
{
45
45
 
46
 
    guint i, j;
 
46
    int16_t i;
 
47
    guint j;
47
48
    gint newwindow = 0;
48
49
    gint loop = 0;
49
50
    gboolean autohref = FALSE;
59
60
    GError *error;
60
61
    NPError nperror;
61
62
    guint32 supportsWindowless = FALSE; // NPBool + padding
 
63
    gchar *app_name;
62
64
 
63
65
    if (instance->mode == NP_EMBED) {
64
66
        for (i = 0; i < argc; i++) {
 
67
        
 
68
            if (argn[i] == NULL)
 
69
                continue;
 
70
                
65
71
            printf("ARG: %s = %s\n", argn[i], argv[i]);
66
72
 
67
73
            if (g_ascii_strcasecmp(argn[i], "name") == 0) {
103
109
                sscanf(argv[i], "%i", &height);
104
110
            }
105
111
 
106
 
            if (g_ascii_strcasecmp(argn[i], "src") == 0) {
 
112
            if (g_ascii_strcasecmp(argn[i], "src") == 0
 
113
                || g_ascii_strcasecmp(argn[i], "url") == 0) {
107
114
                item = g_new0(ListItem, 1);
108
 
                g_strlcpy(item->src, argv[i], 4096);
 
115
                if (g_strrstr(argv[i],"XXmovies.apple.com")) {  // tmp disabled, to reenable remove XX
 
116
                    tmp = g_strrstr(argv[i], "movies.");
 
117
                    if (tmp != NULL && strlen(tmp) > strlen("movies.")) {
 
118
                        tmp = tmp + strlen("movies.");    
 
119
                        g_snprintf(item->src, 4096, "http://www.%s", tmp);  
 
120
                    } else {
 
121
                        g_strlcpy(item->src, argv[i], 4096);
 
122
                    }               
 
123
                } else {
 
124
                    g_strlcpy(item->src, argv[i], 4096);
 
125
                }
109
126
                // printf("Item src = %s\n",item->src);
110
127
                item->streaming = streaming(item->src);
111
128
                item->play = TRUE;
112
129
                item->id = instance->nextid++;
113
 
                //if (g_strrstr(argv[i],"apple.com"))
114
 
                //    setPreference(instance, "general.useragent.override","QuickTime/7.6.2");
115
130
                instance->playlist = g_list_append(instance->playlist, item);
116
131
                src = item;
117
132
            }
129
144
 
130
145
            if (g_ascii_strcasecmp(argn[i], "href") == 0) {
131
146
                item = g_new0(ListItem, 1);
132
 
                g_strlcpy(item->src, argv[i], 4096);
 
147
                if (g_strrstr(argv[i],"XXmovies.apple.com")) {
 
148
                    tmp = g_strrstr(argv[i], "movies.");
 
149
                    if (tmp != NULL && strlen(tmp) > strlen("movies.")) {
 
150
                        tmp = tmp + strlen("movies.");    
 
151
                        g_snprintf(item->src, 4096, "http://www.%s", tmp);  
 
152
                    } else {
 
153
                        g_strlcpy(item->src, argv[i], 4096);
 
154
                    }               
 
155
                } else {
 
156
                    g_strlcpy(item->src, argv[i], 4096);
 
157
                }
133
158
                // printf("Item href = %s\n",item->src);
134
159
                item->streaming = streaming(item->src);
135
160
                item->play = FALSE;
169
194
            if (g_ascii_strcasecmp(argn[i], "target") == 0) {
170
195
                if (g_ascii_strcasecmp(argv[i], "quicktimeplayer") == 0) {
171
196
                    newwindow = TRUE;
172
 
                }
 
197
                } else {
 
198
                        item = g_new0(ListItem, 1);
 
199
                        g_strlcpy(item->src, argv[i], 4096);
 
200
                        // printf("Item href = %s\n",item->src);
 
201
                        item->streaming = streaming(item->src);
 
202
                        item->play = FALSE;
 
203
                        item->id = instance->nextid++;
 
204
                        instance->playlist = g_list_append(instance->playlist, item);
 
205
                        src = item;
 
206
                        instance->show_controls = 0;
 
207
                }
 
208
 
173
209
            }
174
210
 
175
211
            if (g_ascii_strcasecmp(argn[i], "hidden") == 0) {
205
241
            if (g_ascii_strcasecmp(argn[i], "autohref") == 0) {
206
242
                if (strstr(argv[i], "true")
207
243
                    || strstr(argv[i], "yes")
 
244
                    || strstr(argv[i], "autohref")
208
245
                    || strstr(argv[i], "1")) {
209
246
                    autohref = TRUE;
210
247
                } else {
211
248
                    autohref = FALSE;
212
249
                }
213
250
            }
 
251
            
 
252
            if (g_ascii_strcasecmp(argn[i], "data") == 0) {
 
253
                // autohref = TRUE;
 
254
            }
214
255
 
215
256
            if ((g_ascii_strcasecmp(argn[i], "autoplay") == 0)
216
257
                || (g_ascii_strcasecmp(argn[i], "autostart") == 0)) {
344
385
                    || g_ascii_strcasecmp(argv[i], "yes") == 0
345
386
                    || g_ascii_strcasecmp(argv[i], "1") == 0) {
346
387
                    instance->debug = TRUE;
 
388
                                                   
347
389
                } else {
348
390
                    instance->debug = FALSE;
349
391
                }
359
401
                }
360
402
            }
361
403
 
 
404
            if (g_ascii_strncasecmp(argn[i], "qtnext",6) == 0) {
 
405
                parse = g_strsplit_set(argv[i],"<>",0);
 
406
                if (parse[1] != NULL) {
 
407
                    item = g_new0(ListItem, 1);
 
408
                    tmp = g_strrstr(src->src, "/");
 
409
                    if (tmp) {
 
410
                        g_strlcpy(item->src, src->src, 1024);
 
411
                        tmp = g_strrstr(item->src, "/");
 
412
                        tmp[1] = '\0';
 
413
                        g_strlcat(item->src, parse[1], 4096);
 
414
                    } else {
 
415
                        g_strlcpy(item->src, parse[1], 4096);
 
416
                    }
 
417
                    item->streaming = streaming(item->src);
 
418
                    item->play = TRUE;
 
419
                    item->id = instance->nextid++;
 
420
                    instance->playlist = g_list_append(instance->playlist, item);
 
421
                }        
 
422
                g_strfreev(parse);
 
423
            }
 
424
 
362
425
        };
363
426
    } else {
364
427
 
389
452
    if (href != NULL && src != NULL) {
390
453
        src->hrefid = href->id;
391
454
    }
 
455
        
392
456
    // if target is set, set it on the href
393
457
    if (href != NULL) {
394
458
        href->newwindow = newwindow;
430
494
        // generate a random controlid
431
495
        rand = g_rand_new();
432
496
        href->controlid = g_rand_int_range(rand, 0, 65535);
 
497
        // printf("autohref controlid = %i\n", href->controlid);
433
498
        g_rand_free(rand);
434
 
        tmp = g_strdup_printf("/control/%i", item->controlid);
 
499
        tmp = g_strdup_printf("/control/%i", href->controlid);
435
500
        g_strlcpy(href->path, tmp, 1024);
436
501
        g_free(tmp);
437
502
 
438
503
        //list_dump(instance->playlist);
 
504
        app_name = NULL;
 
505
        if (instance->player_backend != NULL) {
 
506
            app_name = g_find_program_in_path(instance->player_backend);
 
507
        }
 
508
        if (app_name == NULL) {
 
509
            app_name = g_find_program_in_path("gnome-mplayer");
 
510
            if (app_name == NULL)
 
511
                app_name = g_find_program_in_path("gnome-mplayer-minimal");
 
512
        }
439
513
 
440
 
        arg[i++] = g_strdup("gnome-mplayer");
441
 
        arg[i++] = g_strdup_printf("--controlid=%i", item->controlid);
 
514
        arg[i++] = g_strdup(app_name);
 
515
        arg[i++] = g_strdup_printf("--controlid=%i", href->controlid);
442
516
        arg[i] = NULL;
443
517
        error = NULL;
444
518
        if (g_spawn_async(NULL, arg, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, &error) == FALSE) {
447
521
            error = NULL;
448
522
        }
449
523
        NPN_GetURLNotify(instance->mInstance, href->src, NULL, href);
 
524
        g_free(app_name);
450
525
    }
451
526
 
452
527
 
475
550
    if (g_ascii_strncasecmp(url, "dvd://", 6) == 0)
476
551
        ret = 1;
477
552
 
 
553
    if (g_strrstr(url, ".m3u") != NULL)
 
554
        ret = 1;
 
555
 
478
556
    if (g_ascii_strncasecmp(url, "file://", 7) == 0) {
479
557
        p = g_filename_from_uri(url, NULL, NULL);
480
558
        if (p != NULL) {