Mercurial > pidgin
comparison src/plugins.c @ 153:8ed64c704fb0
[gaim-migrate @ 163]
This should be interesting. We'll see how well this works. I can't explain
why, but I have a bad feeling about this one.
committer: Tailor Script <tailor@pidgin.im>
| author | Eric Warmenhoven <eric@warmenhoven.org> |
|---|---|
| date | Mon, 24 Apr 2000 01:47:24 +0000 |
| parents | fbabd28795d2 |
| children | 1c4e47c0c5dd |
comparison
equal
deleted
inserted
replaced
| 152:cb0d3ec5a4c8 | 153:8ed64c704fb0 |
|---|---|
| 84 } | 84 } |
| 85 | 85 |
| 86 static void load_file(GtkWidget *w, gpointer data) | 86 static void load_file(GtkWidget *w, gpointer data) |
| 87 { | 87 { |
| 88 char *buf = g_malloc(BUF_LEN); | 88 char *buf = g_malloc(BUF_LEN); |
| 89 FILE *fd; | |
| 89 | 90 |
| 90 if (plugin_dialog) { | 91 if (plugin_dialog) { |
| 91 g_free(buf); | 92 g_free(buf); |
| 92 gtk_widget_show(plugin_dialog); | 93 gtk_widget_show(plugin_dialog); |
| 93 gdk_window_raise(plugin_dialog->window); | 94 gdk_window_raise(plugin_dialog->window); |
| 97 plugin_dialog = gtk_file_selection_new("Gaim - Plugin List"); | 98 plugin_dialog = gtk_file_selection_new("Gaim - Plugin List"); |
| 98 | 99 |
| 99 gtk_file_selection_hide_fileop_buttons( | 100 gtk_file_selection_hide_fileop_buttons( |
| 100 GTK_FILE_SELECTION(plugin_dialog)); | 101 GTK_FILE_SELECTION(plugin_dialog)); |
| 101 | 102 |
| 102 if(getenv("PLUGIN_DIR") == NULL) { | 103 g_snprintf(buf, BUF_LEN - 1, "%s/%s", getenv("HOME"), PLUGIN_DIR); |
| 103 g_snprintf(buf, BUF_LEN - 1, "%s/%s", getenv("HOME"), PLUGIN_DIR); | 104 fd = fopen(buf, "r"); |
| 104 } else { | 105 if (!fd) |
| 105 g_snprintf(buf, BUF_LEN - 1, "%s/", getenv("PLUGIN_DIR")); | 106 mkdir(buf, S_IRUSR | S_IWUSR | S_IXUSR); |
| 106 } | 107 else |
| 108 fclose(fd); | |
| 107 | 109 |
| 108 gtk_file_selection_set_filename(GTK_FILE_SELECTION(plugin_dialog), buf); | 110 gtk_file_selection_set_filename(GTK_FILE_SELECTION(plugin_dialog), buf); |
| 111 gtk_file_selection_complete(GTK_FILE_SELECTION(plugin_dialog), "*.so"); | |
| 109 gtk_signal_connect(GTK_OBJECT(plugin_dialog), "destroy", | 112 gtk_signal_connect(GTK_OBJECT(plugin_dialog), "destroy", |
| 110 GTK_SIGNAL_FUNC(destroy_plugins), plugin_dialog); | 113 GTK_SIGNAL_FUNC(destroy_plugins), plugin_dialog); |
| 111 | 114 |
| 112 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(plugin_dialog)->ok_button), | 115 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(plugin_dialog)->ok_button), |
| 113 "clicked", GTK_SIGNAL_FUNC(load_which_plugin), NULL); | 116 "clicked", GTK_SIGNAL_FUNC(load_which_plugin), NULL); |
| 133 struct gaim_plugin *plug; | 136 struct gaim_plugin *plug; |
| 134 void (*gaim_plugin_init)(); | 137 void (*gaim_plugin_init)(); |
| 135 char *(*cfunc)(); | 138 char *(*cfunc)(); |
| 136 char *error; | 139 char *error; |
| 137 | 140 |
| 141 if (filename == NULL) return; | |
| 138 plug = g_malloc(sizeof *plug); | 142 plug = g_malloc(sizeof *plug); |
| 139 plug->filename = g_strdup(filename); | 143 if (filename[0] != '/') { |
| 144 char *buf = g_malloc(BUF_LEN); | |
| 145 g_snprintf(buf, BUF_LEN - 1, "%s/%s", getenv("HOME"), PLUGIN_DIR); | |
| 146 plug->filename = g_malloc(strlen(buf) + strlen(filename) + 1); | |
| 147 sprintf(plug->filename, "%s%s", buf, filename); | |
| 148 } else | |
| 149 plug->filename = g_strdup(filename); | |
| 140 /* do NOT OR with RTLD_GLOBAL, otherwise plugins may conflict | 150 /* do NOT OR with RTLD_GLOBAL, otherwise plugins may conflict |
| 141 * (it's really just a way to work around other people's bad | 151 * (it's really just a way to work around other people's bad |
| 142 * programming, by not using RTLD_GLOBAL :P ) */ | 152 * programming, by not using RTLD_GLOBAL :P ) */ |
| 143 plug->handle = dlopen(plug->filename, RTLD_LAZY); | 153 plug->handle = dlopen(plug->filename, RTLD_LAZY); |
| 144 if (!plug->handle) { | 154 if (!plug->handle) { |
| 170 plug->description = (*cfunc)(); | 180 plug->description = (*cfunc)(); |
| 171 else | 181 else |
| 172 plug->description = NULL; | 182 plug->description = NULL; |
| 173 | 183 |
| 174 update_show_plugins(); | 184 update_show_plugins(); |
| 185 save_prefs(); | |
| 175 } | 186 } |
| 176 | 187 |
| 177 void show_plugins(GtkWidget *w, gpointer data) { | 188 void show_plugins(GtkWidget *w, gpointer data) { |
| 178 /* most of this code was shamelessly stolen from prefs.c */ | 189 /* most of this code was shamelessly stolen from prefs.c */ |
| 179 GtkWidget *page; | 190 GtkWidget *page; |
