Update of /cvsroot/mplayerplug-in/mplayerplug-in/Source
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15006/Source
Modified Files:
plugin-setup.cpp plugin-support.cpp plugin-ui.cpp plugin.cpp
Log Message:
Changed the way config files are read... /etc is read first, then $HOME/.mozilla then $HOME/.mplayer
Updated config dialog to update config file options for vo,ao,cachesize and cache-percent settings (need localization)
Fix crash when switching away from stopped/paused media
Index: plugin-ui.cpp
===================================================================
RCS file: /cvsroot/mplayerplug-in/mplayerplug-in/Source/plugin-ui.cpp,v
retrieving revision 1.120
retrieving revision 1.121
diff -C2 -d -r1.120 -r1.121
*** plugin-ui.cpp 23 Jul 2005 22:39:14 -0000 1.120
--- plugin-ui.cpp 24 Jul 2005 15:46:35 -0000 1.121
***************
*** 1600,1604 ****
}
! gint CloseConfig(GtkWidget *widget, gpointer gdata){
gtk_widget_destroy(widget);
--- 1600,1605 ----
}
! gint CloseConfig(GtkWidget * widget, gpointer gdata)
! {
gtk_widget_destroy(widget);
***************
*** 1607,1622 ****
}
! gint ApplyConfig(GtkWidget *widget, nsPluginInstance * instance) {
! instance->cachesize = (int)gtk_range_get_value(GTK_RANGE(instance->conf_cachesize));
! instance->cache_percent = (int)gtk_range_get_value(GTK_RANGE(instance->conf_cachepercent));
! if (instance->vo != NULL)
free(instance->vo);
! instance->vo =strdup(gtk_entry_get_text(GTK_ENTRY(GTK_BIN(instance->conf_vo)->child)));
if (instance->ao != NULL)
free(instance->ao);
! instance->ao =strdup(gtk_entry_get_text(GTK_ENTRY(GTK_BIN(instance->conf_ao)->child)));
gtk_widget_destroy(instance->conf_window);
--- 1608,1636 ----
}
! #ifdef GTK2_ENABLED
! gint ApplyConfig(GtkWidget * widget, nsPluginInstance * instance)
! {
! FILE *input;
! FILE *output;
! char config_name[1000];
! char tmp_name[1000];
! char buffer[1000];
! instance->cachesize =
! (int) gtk_range_get_value(GTK_RANGE(instance->conf_cachesize));
! instance->cache_percent =
! (int) gtk_range_get_value(GTK_RANGE(instance->conf_cachepercent));
! if (instance->vo != NULL)
free(instance->vo);
! instance->vo =
! strdup(gtk_entry_get_text
! (GTK_ENTRY(GTK_BIN(instance->conf_vo)->child)));
if (instance->ao != NULL)
free(instance->ao);
! instance->ao =
! strdup(gtk_entry_get_text
! (GTK_ENTRY(GTK_BIN(instance->conf_ao)->child)));
gtk_widget_destroy(instance->conf_window);
***************
*** 1624,1729 ****
// write the setting to the conf file now
! return(FALSE);
}
void menuitem_config_callback(GtkMenuItem * menuitem,
! nsPluginInstance * instance)
{
! GtkWidget *conf_vbox;
! GtkWidget *conf_hbutton_box;
! GtkWidget *conf_ok;
! GtkWidget *conf_cancel;
! GtkWidget *conf_table;
! GtkWidget *conf_label;
! instance->conf_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
! conf_vbox = gtk_vbox_new(FALSE,10);
! conf_hbutton_box = gtk_hbutton_box_new();
! conf_table = gtk_table_new(10,2,FALSE);
! gtk_container_add(GTK_CONTAINER(conf_vbox),conf_table);
! gtk_container_add(GTK_CONTAINER(conf_vbox),conf_hbutton_box);
! gtk_container_add(GTK_CONTAINER(instance->conf_window),conf_vbox);
! gtk_window_set_title(GTK_WINDOW(instance->conf_window) , "mplayerplug-in configuration");
! gtk_container_set_border_width(GTK_CONTAINER(instance->conf_window),5);
! g_signal_connect (GTK_OBJECT(instance->conf_window), "delete_event", GTK_SIGNAL_FUNC(CloseConfig), NULL);
! instance->conf_vo = gtk_combo_box_entry_new_text();
! gtk_combo_box_append_text(GTK_COMBO_BOX(instance->conf_vo),"x11");
! if (strcmp(instance->vo,"x11") == 0)
! gtk_combo_box_set_active(GTK_COMBO_BOX(instance->conf_vo),0);
! gtk_combo_box_append_text(GTK_COMBO_BOX(instance->conf_vo),"xv");
! if (strcmp(instance->vo,"xv") == 0)
! gtk_combo_box_set_active(GTK_COMBO_BOX(instance->conf_vo),1);
! if (gtk_combo_box_get_active(GTK_COMBO_BOX(instance->conf_vo)) == -1) {
! gtk_combo_box_append_text(GTK_COMBO_BOX(instance->conf_vo),instance->vo);
! gtk_combo_box_set_active(GTK_COMBO_BOX(instance->conf_vo),2);
! }
! instance->conf_ao = gtk_combo_box_entry_new_text();
! gtk_combo_box_append_text(GTK_COMBO_BOX(instance->conf_ao),"alsa");
! if (strcmp(instance->ao,"alsa") == 0)
! gtk_combo_box_set_active(GTK_COMBO_BOX(instance->conf_ao),0);
! gtk_combo_box_append_text(GTK_COMBO_BOX(instance->conf_ao),"arts");
! if (strcmp(instance->ao,"arts") == 0)
! gtk_combo_box_set_active(GTK_COMBO_BOX(instance->conf_ao),1);
! gtk_combo_box_append_text(GTK_COMBO_BOX(instance->conf_ao),"esd");
! if (strcmp(instance->ao,"esd") == 0)
! gtk_combo_box_set_active(GTK_COMBO_BOX(instance->conf_ao),2);
! gtk_combo_box_append_text(GTK_COMBO_BOX(instance->conf_ao),"oss");
! if (strcmp(instance->ao,"oss") == 0)
! gtk_combo_box_set_active(GTK_COMBO_BOX(instance->conf_ao),3);
! if (gtk_combo_box_get_active(GTK_COMBO_BOX(instance->conf_ao)) == -1) {
! gtk_combo_box_append_text(GTK_COMBO_BOX(instance->conf_ao),instance->ao);
! gtk_combo_box_set_active(GTK_COMBO_BOX(instance->conf_ao),4);
! }
! conf_ok = gtk_button_new_with_label(_("OK"));
! g_signal_connect (GTK_OBJECT(conf_ok), "clicked", GTK_SIGNAL_FUNC(ApplyConfig), instance);
! conf_cancel = gtk_button_new_with_label(_("Cancel"));
! g_signal_connect_swapped(GTK_OBJECT(conf_cancel), "clicked", GTK_SIGNAL_FUNC(CloseConfig), GTK_OBJECT(instance->conf_window));
! conf_label = gtk_label_new("VO:");
! gtk_table_attach_defaults(GTK_TABLE(conf_table),conf_label,0,1,0,1);
! gtk_widget_show(conf_label);
! gtk_table_attach_defaults(GTK_TABLE(conf_table),instance->conf_vo,1,2,0,1);
! conf_label = gtk_label_new("AO:");
! gtk_table_attach_defaults(GTK_TABLE(conf_table),conf_label,0,1,1,2);
! gtk_widget_show(conf_label);
! gtk_table_attach_defaults(GTK_TABLE(conf_table),instance->conf_ao,1,2,1,2);
-
- conf_label = gtk_label_new("Cache Size:");
- gtk_table_attach_defaults(GTK_TABLE(conf_table),conf_label,0,1,2,3);
- gtk_widget_show(conf_label);
- instance->conf_cachesize = gtk_hscale_new_with_range(0,65000,1000);
- gtk_table_attach_defaults(GTK_TABLE(conf_table),instance->conf_cachesize,1,2,2,3);
- gtk_range_set_value(GTK_RANGE(instance->conf_cachesize),instance->cachesize);
- gtk_widget_show(instance->conf_cachesize);
! conf_label = gtk_label_new("Cache Percent:");
! gtk_table_attach_defaults(GTK_TABLE(conf_table),conf_label,0,1,3,4);
! gtk_widget_show(conf_label);
! instance->conf_cachepercent = gtk_hscale_new_with_range(0,100,5);
! gtk_table_attach_defaults(GTK_TABLE(conf_table),instance->conf_cachepercent,1,2,3,4);
! gtk_range_set_value(GTK_RANGE(instance->conf_cachepercent),instance->cache_percent);
! gtk_widget_show(instance->conf_cachepercent);
! gtk_container_add(GTK_CONTAINER(conf_hbutton_box),conf_ok);
! gtk_container_add(GTK_CONTAINER(conf_hbutton_box),conf_cancel);
- gtk_widget_show(instance->conf_vo);
- gtk_widget_show(instance->conf_ao);
- gtk_widget_show(conf_ok);
- gtk_widget_show(conf_cancel);
- gtk_widget_show(conf_table);
- gtk_widget_show(conf_hbutton_box);
- gtk_widget_show(conf_vbox);
- gtk_widget_show(instance->conf_window);
! }
#endif
--- 1638,1810 ----
// write the setting to the conf file now
! snprintf(config_name, 1000, "%s", getenv("HOME"));
! strlcat(config_name, "/.mplayer/mplayerplug-in.conf", 1000);
!
! snprintf(tmp_name, 1000, "%s", tempnam("/tmp", "confXXXXXX"));
!
! if (DEBUG) {
! printf("config %s\n", config_name);
! printf("tmp %s\n", tmp_name);
!
! }
!
! input = fopen(config_name, "r");
! output = fopen(tmp_name, "w");
!
! if (input != NULL && output != NULL) {
! if (DEBUG)
! printf("update existing config\n");
! while (fgets(buffer, sizeof(buffer), input) != NULL) {
! if (strncasecmp(buffer, "vo", 2) == 0) {
! } else if (strncasecmp(buffer, "ao", 2) == 0) {
! } else if (strncasecmp(buffer, "cachesize", 9) == 0) {
! } else if (strncasecmp(buffer, "cache-percent", 13) == 0) {
! } else {
! fprintf(output, "%s", buffer);
! }
!
! }
! fprintf(output, "vo=%s\n", instance->vo);
! fprintf(output, "ao=%s\n", instance->ao);
! fprintf(output, "cachesize=%i\n", instance->cachesize);
! fprintf(output, "cache-percent=%i\n", instance->cache_percent);
! fclose(input);
! fclose(output);
! unlink(config_name);
! rename(tmp_name, config_name);
! } else {
! if (DEBUG)
! printf("write new config file\n");
! if (output != NULL) {
! fprintf(output, "vo=%s\n", instance->vo);
! fprintf(output, "ao=%s\n", instance->ao);
! fprintf(output, "cachesize=%i\n", instance->cachesize);
! fprintf(output, "cachepercent=%i\n", instance->cache_percent);
! fclose(output);
! rename(tmp_name, config_name);
! }
!
! }
! return (FALSE);
}
+
void menuitem_config_callback(GtkMenuItem * menuitem,
! nsPluginInstance * instance)
{
! GtkWidget *conf_vbox;
! GtkWidget *conf_hbutton_box;
! GtkWidget *conf_ok;
! GtkWidget *conf_cancel;
! GtkWidget *conf_table;
! GtkWidget *conf_label;
! instance->conf_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
! conf_vbox = gtk_vbox_new(FALSE, 10);
! conf_hbutton_box = gtk_hbutton_box_new();
! conf_table = gtk_table_new(10, 2, FALSE);
! gtk_container_add(GTK_CONTAINER(conf_vbox), conf_table);
! gtk_container_add(GTK_CONTAINER(conf_vbox), conf_hbutton_box);
! gtk_container_add(GTK_CONTAINER(instance->conf_window), conf_vbox);
! gtk_window_set_title(GTK_WINDOW(instance->conf_window),
! "mplayerplug-in configuration");
! gtk_container_set_border_width(GTK_CONTAINER(instance->conf_window),
! 5);
! g_signal_connect(GTK_OBJECT(instance->conf_window), "delete_event",
! GTK_SIGNAL_FUNC(CloseConfig), NULL);
! instance->conf_vo = gtk_combo_box_entry_new_text();
! gtk_combo_box_append_text(GTK_COMBO_BOX(instance->conf_vo), "x11");
! if (strcmp(instance->vo, "x11") == 0)
! gtk_combo_box_set_active(GTK_COMBO_BOX(instance->conf_vo), 0);
! gtk_combo_box_append_text(GTK_COMBO_BOX(instance->conf_vo), "xv");
! if (strcmp(instance->vo, "xv") == 0)
! gtk_combo_box_set_active(GTK_COMBO_BOX(instance->conf_vo), 1);
! if (gtk_combo_box_get_active(GTK_COMBO_BOX(instance->conf_vo)) == -1) {
! gtk_combo_box_append_text(GTK_COMBO_BOX(instance->conf_vo),
! instance->vo);
! gtk_combo_box_set_active(GTK_COMBO_BOX(instance->conf_vo), 2);
! }
! instance->conf_ao = gtk_combo_box_entry_new_text();
! gtk_combo_box_append_text(GTK_COMBO_BOX(instance->conf_ao), "alsa");
! if (strcmp(instance->ao, "alsa") == 0)
! gtk_combo_box_set_active(GTK_COMBO_BOX(instance->conf_ao), 0);
! gtk_combo_box_append_text(GTK_COMBO_BOX(instance->conf_ao), "arts");
! if (strcmp(instance->ao, "arts") == 0)
! gtk_combo_box_set_active(GTK_COMBO_BOX(instance->conf_ao), 1);
! gtk_combo_box_append_text(GTK_COMBO_BOX(instance->conf_ao), "esd");
! if (strcmp(instance->ao, "esd") == 0)
! gtk_combo_box_set_active(GTK_COMBO_BOX(instance->conf_ao), 2);
! gtk_combo_box_append_text(GTK_COMBO_BOX(instance->conf_ao), "oss");
! if (strcmp(instance->ao, "oss") == 0)
! gtk_combo_box_set_active(GTK_COMBO_BOX(instance->conf_ao), 3);
! if (gtk_combo_box_get_active(GTK_COMBO_BOX(instance->conf_ao)) == -1) {
! gtk_combo_box_append_text(GTK_COMBO_BOX(instance->conf_ao),
! instance->ao);
! gtk_combo_box_set_active(GTK_COMBO_BOX(instance->conf_ao), 4);
! }
! conf_ok = gtk_button_new_with_label(_("OK"));
! g_signal_connect(GTK_OBJECT(conf_ok), "clicked",
! GTK_SIGNAL_FUNC(ApplyConfig), instance);
! conf_cancel = gtk_button_new_with_label(_("Cancel"));
! g_signal_connect_swapped(GTK_OBJECT(conf_cancel), "clicked",
! GTK_SIGNAL_FUNC(CloseConfig),
! GTK_OBJECT(instance->conf_window));
! conf_label = gtk_label_new(_("VO:"));
! gtk_table_attach_defaults(GTK_TABLE(conf_table), conf_label, 0, 1, 0,
! 1);
! gtk_widget_show(conf_label);
! gtk_table_attach_defaults(GTK_TABLE(conf_table), instance->conf_vo, 1,
! 2, 0, 1);
! conf_label = gtk_label_new(_("AO:"));
! gtk_table_attach_defaults(GTK_TABLE(conf_table), conf_label, 0, 1, 1,
! 2);
! gtk_widget_show(conf_label);
! gtk_table_attach_defaults(GTK_TABLE(conf_table), instance->conf_ao, 1,
! 2, 1, 2);
! conf_label = gtk_label_new(_("Cache Size:"));
! gtk_table_attach_defaults(GTK_TABLE(conf_table), conf_label, 0, 1, 2,
! 3);
! gtk_widget_show(conf_label);
! instance->conf_cachesize = gtk_hscale_new_with_range(0, 32767, 1024);
! gtk_table_attach_defaults(GTK_TABLE(conf_table),
! instance->conf_cachesize, 1, 2, 2, 3);
! gtk_range_set_value(GTK_RANGE(instance->conf_cachesize),
! instance->cachesize);
! gtk_widget_show(instance->conf_cachesize);
! conf_label = gtk_label_new(_("Cache Percent:"));
! gtk_table_attach_defaults(GTK_TABLE(conf_table), conf_label, 0, 1, 3,
! 4);
! gtk_widget_show(conf_label);
! instance->conf_cachepercent = gtk_hscale_new_with_range(0, 100, 5);
! gtk_table_attach_defaults(GTK_TABLE(conf_table),
! instance->conf_cachepercent, 1, 2, 3, 4);
! gtk_range_set_value(GTK_RANGE(instance->conf_cachepercent),
! instance->cache_percent);
! gtk_widget_show(instance->conf_cachepercent);
+ gtk_container_add(GTK_CONTAINER(conf_hbutton_box), conf_ok);
+ gtk_container_add(GTK_CONTAINER(conf_hbutton_box), conf_cancel);
! gtk_widget_show(instance->conf_vo);
! gtk_widget_show(instance->conf_ao);
! gtk_widget_show(conf_ok);
! gtk_widget_show(conf_cancel);
! gtk_widget_show(conf_table);
! gtk_widget_show(conf_hbutton_box);
! gtk_widget_show(conf_vbox);
! gtk_widget_show(instance->conf_window);
+ }
+ #endif
#endif
Index: plugin-support.cpp
===================================================================
RCS file: /cvsroot/mplayerplug-in/mplayerplug-in/Source/plugin-support.cpp,v
retrieving revision 1.75
retrieving revision 1.76
diff -C2 -d -r1.75 -r1.76
*** plugin-support.cpp 22 Jul 2005 17:34:21 -0000 1.75
--- plugin-support.cpp 24 Jul 2005 15:46:35 -0000 1.76
***************
*** 83,87 ****
hostname = NULL;
} else {
! hostname[i] = '\0';
}
if (DEBUG > 1)
--- 83,87 ----
hostname = NULL;
} else {
! hostname[i] = '\0';
}
if (DEBUG > 1)
***************
*** 205,209 ****
char *hostname1; // hostname1
char *hostname2; // hostname2
! char *protocol1 = NULL;
char *protocol2 = NULL;
int ret;
--- 205,209 ----
char *hostname1; // hostname1
char *hostname2; // hostname2
! char *protocol1 = NULL;
char *protocol2 = NULL;
int ret;
***************
*** 278,287 ****
// compare the paths, some sites change the hostname mid stream (like cartoonnetwork.com -> http://www.cartoonnetwork.com);
tmp1 = strstr(buffer1, "://");
! protocol1 = (char*)malloc((long)tmp1 - (long) buffer1 + 1);
! strncpy(protocol1, buffer1,(long)tmp1 - (long) buffer1 + 1);
! protocol1[(long)tmp1 - (long) buffer1] = '\0';
if (DEBUG > 1)
! printf("protocol1: %s\n",protocol1);
if (tmp1 != NULL) {
--- 278,287 ----
// compare the paths, some sites change the hostname mid stream (like cartoonnetwork.com -> http://www.cartoonnetwork.com);
tmp1 = strstr(buffer1, "://");
! protocol1 = (char *) malloc((long) tmp1 - (long) buffer1 + 1);
! strncpy(protocol1, buffer1, (long) tmp1 - (long) buffer1 + 1);
! protocol1[(long) tmp1 - (long) buffer1] = '\0';
if (DEBUG > 1)
! printf("protocol1: %s\n", protocol1);
if (tmp1 != NULL) {
***************
*** 294,303 ****
}
tmp2 = strstr(buffer2, "://");
! protocol2 = (char*)malloc((long)tmp2 - (long) buffer2 + 1);
! strncpy(protocol2, buffer2, (long)tmp2 - (long) buffer2 + 1);
! protocol2[(long)tmp2 - (long) buffer2] = '\0';
if (DEBUG > 1)
! printf("protocol2: %s\n",protocol2);
if (tmp2 != NULL) {
--- 294,303 ----
}
tmp2 = strstr(buffer2, "://");
! protocol2 = (char *) malloc((long) tmp2 - (long) buffer2 + 1);
! strncpy(protocol2, buffer2, (long) tmp2 - (long) buffer2 + 1);
! protocol2[(long) tmp2 - (long) buffer2] = '\0';
if (DEBUG > 1)
! printf("protocol2: %s\n", protocol2);
if (tmp2 != NULL) {
***************
*** 311,321 ****
if (tmp1 != NULL && tmp2 != NULL) {
if (strcmp(tmp1, tmp2) == 0) {
! if ((strncmp(protocol1,"file://",7) == 0) || (strncmp(protocol2,"file://",7) == 0)) {
ret = 0;
} else {
! if (strcmp(protocol1, protocol2) == 0){
! ret = 0;
} else {
! ret = -1;
}
}
--- 311,322 ----
if (tmp1 != NULL && tmp2 != NULL) {
if (strcmp(tmp1, tmp2) == 0) {
! if ((strncmp(protocol1, "file://", 7) == 0)
! || (strncmp(protocol2, "file://", 7) == 0)) {
ret = 0;
} else {
! if (strcmp(protocol1, protocol2) == 0) {
! ret = 0;
} else {
! ret = -1;
}
}
***************
*** 589,600 ****
} else {
if (instance->hostname != NULL) {
! if (fexists(item) == 0 ) {
snprintf(tmpdir, 1024, "http://%s%s",
! instance->hostname, item);
strlcpy(localitem, tmpdir, 1024);
} else {
// first char == / and hostname is null, sounds like a filename
strlcpy(localitem, item, 1024);
! }
} else {
// first char == / and hostname is null, sounds like a filename
--- 590,601 ----
} else {
if (instance->hostname != NULL) {
! if (fexists(item) == 0) {
snprintf(tmpdir, 1024, "http://%s%s",
! instance->hostname, item);
strlcpy(localitem, tmpdir, 1024);
} else {
// first char == / and hostname is null, sounds like a filename
strlcpy(localitem, item, 1024);
! }
} else {
// first char == / and hostname is null, sounds like a filename
Index: plugin-setup.cpp
===================================================================
RCS file: /cvsroot/mplayerplug-in/mplayerplug-in/Source/plugin-setup.cpp,v
retrieving revision 1.69
retrieving revision 1.70
diff -C2 -d -r1.69 -r1.70
*** plugin-setup.cpp 23 Jul 2005 22:39:14 -0000 1.69
--- plugin-setup.cpp 24 Jul 2005 15:46:35 -0000 1.70
***************
*** 48,51 ****
--- 48,65 ----
char customline[255];
#endif
+ char config_name[3][1000];
+
+ // load config file
+
+ snprintf(config_name[0], 1000, "/etc/mplayerplug-in.conf");
+
+ snprintf(config_name[1], 1000, "%s", getenv("HOME"));
+ strlcat(config_name[1], "/.mozilla/mplayerplug-in.conf", 1000);
+
+ snprintf(config_name[2], 1000, "%s", getenv("HOME"));
+ strlcat(config_name[2], "/.mplayer/mplayerplug-in.conf", 1000);
+
+ config = NULL;
+
enable_mpeg = 1;
***************
*** 64,130 ****
config = NULL;
! if (config == NULL) {
! snprintf(buffer, 1000, "%s", getenv("HOME"));
! strlcat(buffer, "/.mplayer/mplayerplug-in.conf", 1000);
! config = fopen(buffer, "r");
! }
!
! if (config == NULL) {
! snprintf(buffer, 1000, "%s", getenv("HOME"));
! strlcat(buffer, "/.mozilla/mplayerplug-in.conf", 1000);
! config = fopen(buffer, "r");
! }
! if (config == NULL) {
! config = fopen("/etc/mplayerplug-in.conf", "r");
! }
! if (config == NULL) {
! // no config file
! } else {
! while (fgets(buffer, 1000, config) != NULL) {
! if (DEBUG)
! printf("Buffer: %s\n", buffer);
! // SMIL
! if (strncasecmp(buffer, "enable-smil", 11) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &enable_smil);
! if (DEBUG)
! printf("real:%i\n", enable_smil);
! continue;
! }
! // MPEG
! if (strncasecmp(buffer, "enable-mpeg", 11) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &enable_mpeg);
! if (DEBUG)
! printf("mpeg:%i\n", enable_mpeg);
! continue;
! }
! // Ogg Vorbis
! if (strncasecmp(buffer, "enable-ogg", 11) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &enable_ogg);
! if (DEBUG)
! printf("ogg:%i\n", enable_ogg);
! continue;
! }
- if (strncasecmp(buffer, "use-mimetypes", 13) == 0) {
- snprintf(parse, 1000, "%s", strtok(buffer, "="));
- snprintf(parse, 1000, "%s", strtok(NULL, "="));
- sscanf(parse, "%i", &use_custom_mime_types);
- if (DEBUG)
- printf("custom mimetypes:%i\n", use_custom_mime_types);
- continue;
}
!
}
- fclose(config);
}
--- 78,133 ----
config = NULL;
! for (i = 0; i < 3; i++) {
! config = fopen(config_name[i], "r");
! if (config == NULL) {
! // no config file
! } else {
! while (fgets(buffer, 1000, config) != NULL) {
! if (DEBUG)
! printf("Buffer: %s\n", buffer);
! // SMIL
! if (strncasecmp(buffer, "enable-smil", 11) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &enable_smil);
! if (DEBUG)
! printf("real:%i\n", enable_smil);
! continue;
! }
! // MPEG
! if (strncasecmp(buffer, "enable-mpeg", 11) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &enable_mpeg);
! if (DEBUG)
! printf("mpeg:%i\n", enable_mpeg);
! continue;
! }
! // Ogg Vorbis
! if (strncasecmp(buffer, "enable-ogg", 11) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &enable_ogg);
! if (DEBUG)
! printf("ogg:%i\n", enable_ogg);
! continue;
! }
! if (strncasecmp(buffer, "use-mimetypes", 13) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &use_custom_mime_types);
! if (DEBUG)
! printf("custom mimetypes:%i\n",
! use_custom_mime_types);
! continue;
! }
}
! fclose(config);
}
}
***************
*** 682,945 ****
FILE *config;
char buffer[1000];
char parse[1000];
// load config file
! config = NULL;
! if (config == NULL) {
! snprintf(buffer, 1000, "%s", getenv("HOME"));
! strlcat(buffer, "/.mplayer/mplayerplug-in.conf", 1000);
! config = fopen(buffer, "r");
! }
! if (config == NULL) {
! snprintf(buffer, 1000, "%s", getenv("HOME"));
! strlcat(buffer, "/.mozilla/mplayerplug-in.conf", 1000);
! config = fopen(buffer, "r");
! }
! if (config == NULL) {
! config = fopen("/etc/mplayerplug-in.conf", "r");
! }
! if (config == NULL) {
! // no config file
! } else {
! while (fgets(buffer, sizeof(buffer), config) != NULL) {
! if ((strncasecmp(buffer, "cachesize", 9) == 0)
! || (strncasecmp(buffer, "cachemin", 8) == 0)) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &instance->cachesize);
! if (instance->cachesize < 0)
! instance->cachesize = 0;
! if (instance->cachesize > 65535)
! instance->cachesize = 65535;
! continue;
! }
! if (strncasecmp(buffer, "debug", 5) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &DEBUG);
// if (DEBUG != 0)
// DEBUG = 1;
! continue;
! }
! if (strncasecmp(buffer, "novop", 5) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &instance->novop);
! if (instance->novop != 0)
! instance->novop = 1;
! continue;
! }
! if (strncasecmp(buffer, "noembed", 7) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &instance->noembed);
! if (instance->noembed != 0)
! instance->noembed = 1;
! continue;
! }
! if (strncasecmp(buffer, "nomediacache", 12) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &instance->nomediacache);
! if (instance->nomediacache != 0)
! instance->nomediacache = 1;
! continue;
! }
! if (strncasecmp(buffer, "vopopt", 6) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "\n"));
! instance->novop = 0;
! instance->vop = strdup(parse);
! continue;
! }
! if (strncasecmp(buffer, "prefer-aspect", 13) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &instance->maintain_aspect);
! if (instance->maintain_aspect != 0)
! instance->maintain_aspect = 1;
! continue;
! }
! if (strncasecmp(buffer, "rtsp-use-tcp", 12) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &instance->rtsp_use_tcp);
! if (instance->rtsp_use_tcp != 0)
! instance->rtsp_use_tcp = 1;
! continue;
! }
! if (strncasecmp(buffer, "qt-speed", 8) == 0) {
! sprintf(parse, "%s", strtok(buffer, "="));
! sprintf(parse, "%s", strtok(NULL, "="));
! if (strncasecmp(parse, "low", 3) == 0)
! instance->qt_speed = SPEED_LOW;
! if (strncasecmp(parse, "medium", 6) == 0)
! instance->qt_speed = SPEED_MED;
! if (strncasecmp(parse, "high", 4) == 0)
! instance->qt_speed = SPEED_HIGH;
! if (DEBUG)
! printf("QT Speed: %i\n", instance->qt_speed);
! continue;
! }
! if (strncasecmp(buffer, "vo", 2) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "=\n"));
! instance->vo = strdup(parse);
! continue;
! }
! if (strncasecmp(buffer, "ao", 2) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "\n"));
! instance->ao = strdup(parse);
! continue;
! }
! if (strncasecmp(buffer, "display", 7) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "=\n"));
! instance->output_display = strdup(parse);
! continue;
! }
! if (strncasecmp(buffer, "dload-dir", 9) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "=\n"));
! if (strstr(parse, "$HOME") != NULL) {
! snprintf(buffer, sizeof(buffer), "%s%s",
! getenv("HOME"), parse + 5);
! strlcpy(parse, buffer, sizeof(parse));
}
- if (instance->download_dir != NULL)
- free(instance->download_dir);
- instance->download_dir = strdup(parse);
- continue;
- }
! if (strncasecmp(buffer, "keep-download", 13) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &instance->keep_download);
! if (instance->keep_download != 0)
! instance->keep_download = 1;
! continue;
! }
! if (strncasecmp(buffer, "framedrop", 9) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &instance->framedrop);
! if (instance->framedrop != 0)
! instance->framedrop = 1;
! continue;
! }
! if (strncasecmp(buffer, "autosync", 8) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &instance->autosync);
! if (instance->autosync < 0)
! instance->autosync = 0;
! continue;
! }
! if ((strncasecmp(buffer, "autoplay", 8) == 0)
! || (strncasecmp(buffer, "autostart", 9) == 0)) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &instance->autostart);
! if (instance->autostart < 0)
! instance->autostart = 0;
! continue;
! }
! if (strncasecmp(buffer, "mc", 2) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &instance->mc);
! if (instance->mc < 0)
! instance->mc = 0;
! continue;
! }
! if (strncasecmp(buffer, "black-background", 16) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &instance->black_background);
! if (instance->black_background != 0)
! instance->black_background = 1;
! continue;
! }
! if (strncasecmp(buffer, "nomouseinput", 12) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &instance->nomouseinput);
! if (instance->nomouseinput != 0)
! instance->nomouseinput = 1;
! continue;
! }
! if (strncasecmp(buffer, "noconsolecontrols", 17) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &instance->noconsolecontrols);
! if (instance->noconsolecontrols != 0)
! instance->noconsolecontrols = 1;
! continue;
! }
! if (strncasecmp(buffer, "cookies", 7) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &instance->cookies);
! if (instance->cookies != 0)
! instance->cookies = 1;
! continue;
! }
! if (strncasecmp(buffer, "osdlevel", 8) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &instance->osdlevel);
! if (instance->osdlevel < 0)
! instance->osdlevel = 0;
! if (instance->osdlevel > 3)
! instance->osdlevel = 3;
! }
! if (strncasecmp(buffer, "cache-percent", 13) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &instance->cache_percent);
! if (instance->cache_percent < 0)
! instance->cache_percent = 0;
! if (instance->cache_percent > 100)
! instance->cache_percent = 100;
! }
! if (strncasecmp(buffer, "user-agent", 10) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "=\n"));
! instance->useragent = strdup(parse);
! continue;
! }
}
}
--- 685,947 ----
FILE *config;
+ int i;
char buffer[1000];
char parse[1000];
+ char config_name[3][1000];
// load config file
! snprintf(config_name[0], 1000, "/etc/mplayerplug-in.conf");
! snprintf(config_name[1], 1000, "%s", getenv("HOME"));
! strlcat(config_name[1], "/.mozilla/mplayerplug-in.conf", 1000);
! snprintf(config_name[2], 1000, "%s", getenv("HOME"));
! strlcat(config_name[2], "/.mplayer/mplayerplug-in.conf", 1000);
! config = NULL;
! for (i = 0; i < 3; i++) {
! config = fopen(config_name[i], "r");
! if (config == NULL) {
! // no config file
! } else {
! while (fgets(buffer, sizeof(buffer), config) != NULL) {
! if ((strncasecmp(buffer, "cachesize", 9) == 0)
! || (strncasecmp(buffer, "cachemin", 8) == 0)) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &instance->cachesize);
! if (instance->cachesize < 0)
! instance->cachesize = 0;
! if (instance->cachesize > 65535)
! instance->cachesize = 65535;
! continue;
! }
!
! if (strncasecmp(buffer, "debug", 5) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &DEBUG);
// if (DEBUG != 0)
// DEBUG = 1;
! continue;
! }
! if (strncasecmp(buffer, "novop", 5) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &instance->novop);
! if (instance->novop != 0)
! instance->novop = 1;
! continue;
! }
! if (strncasecmp(buffer, "noembed", 7) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &instance->noembed);
! if (instance->noembed != 0)
! instance->noembed = 1;
! continue;
! }
! if (strncasecmp(buffer, "nomediacache", 12) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &instance->nomediacache);
! if (instance->nomediacache != 0)
! instance->nomediacache = 1;
! continue;
! }
! if (strncasecmp(buffer, "vopopt", 6) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "\n"));
! instance->novop = 0;
! instance->vop = strdup(parse);
! continue;
! }
! if (strncasecmp(buffer, "prefer-aspect", 13) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &instance->maintain_aspect);
! if (instance->maintain_aspect != 0)
! instance->maintain_aspect = 1;
! continue;
! }
! if (strncasecmp(buffer, "rtsp-use-tcp", 12) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &instance->rtsp_use_tcp);
! if (instance->rtsp_use_tcp != 0)
! instance->rtsp_use_tcp = 1;
! continue;
! }
! if (strncasecmp(buffer, "qt-speed", 8) == 0) {
! sprintf(parse, "%s", strtok(buffer, "="));
! sprintf(parse, "%s", strtok(NULL, "="));
! if (strncasecmp(parse, "low", 3) == 0)
! instance->qt_speed = SPEED_LOW;
! if (strncasecmp(parse, "medium", 6) == 0)
! instance->qt_speed = SPEED_MED;
! if (strncasecmp(parse, "high", 4) == 0)
! instance->qt_speed = SPEED_HIGH;
! if (DEBUG)
! printf("QT Speed: %i\n", instance->qt_speed);
! continue;
! }
! if (strncasecmp(buffer, "vo", 2) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "=\n"));
! instance->vo = strdup(parse);
! continue;
! }
! if (strncasecmp(buffer, "ao", 2) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "\n"));
! instance->ao = strdup(parse);
! continue;
! }
! if (strncasecmp(buffer, "display", 7) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "=\n"));
! instance->output_display = strdup(parse);
! continue;
! }
! if (strncasecmp(buffer, "dload-dir", 9) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "=\n"));
! if (strstr(parse, "$HOME") != NULL) {
! snprintf(buffer, sizeof(buffer), "%s%s",
! getenv("HOME"), parse + 5);
! strlcpy(parse, buffer, sizeof(parse));
! }
! if (instance->download_dir != NULL)
! free(instance->download_dir);
! instance->download_dir = strdup(parse);
! continue;
}
! if (strncasecmp(buffer, "keep-download", 13) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &instance->keep_download);
! if (instance->keep_download != 0)
! instance->keep_download = 1;
! continue;
! }
! if (strncasecmp(buffer, "framedrop", 9) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &instance->framedrop);
! if (instance->framedrop != 0)
! instance->framedrop = 1;
! continue;
! }
! if (strncasecmp(buffer, "autosync", 8) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &instance->autosync);
! if (instance->autosync < 0)
! instance->autosync = 0;
! continue;
! }
! if ((strncasecmp(buffer, "autoplay", 8) == 0)
! || (strncasecmp(buffer, "autostart", 9) == 0)) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &instance->autostart);
! if (instance->autostart < 0)
! instance->autostart = 0;
! continue;
! }
! if (strncasecmp(buffer, "mc", 2) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &instance->mc);
! if (instance->mc < 0)
! instance->mc = 0;
! continue;
! }
! if (strncasecmp(buffer, "black-background", 16) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &instance->black_background);
! if (instance->black_background != 0)
! instance->black_background = 1;
! continue;
! }
! if (strncasecmp(buffer, "nomouseinput", 12) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &instance->nomouseinput);
! if (instance->nomouseinput != 0)
! instance->nomouseinput = 1;
! continue;
! }
! if (strncasecmp(buffer, "noconsolecontrols", 17) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &instance->noconsolecontrols);
! if (instance->noconsolecontrols != 0)
! instance->noconsolecontrols = 1;
! continue;
! }
! if (strncasecmp(buffer, "cookies", 7) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &instance->cookies);
! if (instance->cookies != 0)
! instance->cookies = 1;
! continue;
! }
! if (strncasecmp(buffer, "osdlevel", 8) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &instance->osdlevel);
! if (instance->osdlevel < 0)
! instance->osdlevel = 0;
! if (instance->osdlevel > 3)
! instance->osdlevel = 3;
! }
! if (strncasecmp(buffer, "cache-percent", 13) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "="));
! sscanf(parse, "%i", &instance->cache_percent);
! if (instance->cache_percent < 0)
! instance->cache_percent = 0;
! if (instance->cache_percent > 100)
! instance->cache_percent = 100;
! }
! if (strncasecmp(buffer, "user-agent", 10) == 0) {
! snprintf(parse, 1000, "%s", strtok(buffer, "="));
! snprintf(parse, 1000, "%s", strtok(NULL, "=\n"));
! instance->useragent = strdup(parse);
! continue;
! }
+ }
+ fclose(config);
}
}
Index: plugin.cpp
===================================================================
RCS file: /cvsroot/mplayerplug-in/mplayerplug-in/Source/plugin.cpp,v
retrieving revision 1.209
retrieving revision 1.210
diff -C2 -d -r1.209 -r1.210
*** plugin.cpp 23 Jul 2005 22:39:14 -0000 1.209
--- plugin.cpp 24 Jul 2005 15:46:35 -0000 1.210
***************
*** 342,348 ****
}
! if (threadsetup == 1) {
! pthread_cancel(player_thread);
! js_state = JS_STATE_UNDEFINED;
}
--- 342,352 ----
}
! if (threadsetup == 1) {
! if (paused == 1)
! sendCommand(this, "pause\n");
! sendCommand(this, "quit\n");
!
! pthread_cancel(player_thread);
! js_state = JS_STATE_UNDEFINED;
}
***************
*** 760,764 ****
GTK_SIGNAL_FUNC(menuitem_copy_callback), this);
gtk_signal_connect(GTK_OBJECT(menuitem_config), "activate",
! GTK_SIGNAL_FUNC(menuitem_config_callback), this);
#endif
--- 764,769 ----
GTK_SIGNAL_FUNC(menuitem_copy_callback), this);
gtk_signal_connect(GTK_OBJECT(menuitem_config), "activate",
! GTK_SIGNAL_FUNC(menuitem_config_callback),
! this);
#endif
***************
*** 1842,1847 ****
void nsPluginInstance::PlayAt(double counter)
{
! starttime = (long int)counter;
! Play();
}
--- 1847,1852 ----
void nsPluginInstance::PlayAt(double counter)
{
! starttime = (long int) counter;
! Play();
}
|