comparison plugins/lagmeter.c @ 1000:91b7377e7b45

[gaim-migrate @ 1010] Plugins work again, I think. There may still be some bugginess. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Mon, 16 Oct 2000 20:11:18 +0000
parents a05ad732b613
children ece2d1543b20
comparison
equal deleted inserted replaced
999:0b5db8cdd30f 1000:91b7377e7b45
67 pct /= 100; 67 pct /= 100;
68 68
69 gtk_progress_bar_update(GTK_PROGRESS_BAR(my_lagometer), pct); 69 gtk_progress_bar_update(GTK_PROGRESS_BAR(my_lagometer), pct);
70 } 70 }
71 71
72 void check_lag(char **who, char **message, void *m) { 72 void check_lag(struct gaim_connection *gc, char **who, char **message, void *m) {
73 char *name = g_strdup(normalize(*who)); 73 char *name = g_strdup(normalize(*who));
74 if (!strcasecmp(normalize(current_user->username), name) && 74 if (!strcasecmp(normalize(gc->username), name) &&
75 (*message != NULL) && 75 (*message != NULL) &&
76 !strcmp(*message, MY_LAG_STRING)) { 76 !strcmp(*message, MY_LAG_STRING)) {
77 struct timeval tv; 77 struct timeval tv;
78 int ms; 78 int ms;
79 79
87 *message = NULL; 87 *message = NULL;
88 } 88 }
89 g_free(name); 89 g_free(name);
90 } 90 }
91 91
92 void send_lag() { 92 void send_lag(struct gaim_connection *gc) {
93 gettimeofday(&my_lag_tv, NULL); 93 gettimeofday(&my_lag_tv, NULL);
94 serv_send_im(current_user->username, MY_LAG_STRING, 1); 94 serv_send_im(gc, gc->username, MY_LAG_STRING, 1);
95 } 95 }
96 96
97 void gaim_plugin_remove() { 97 void gaim_plugin_remove() {
98 if (check_timeout != -1) 98 if (check_timeout != -1)
99 gtk_timeout_remove(check_timeout); 99 gtk_timeout_remove(check_timeout);
104 104
105 confdlg = NULL; 105 confdlg = NULL;
106 lagbox = NULL; 106 lagbox = NULL;
107 } 107 }
108 108
109 void avail_now(void *m) { 109 void avail_now(struct gaim_connection *gc, void *m) {
110 update_lag(0); 110 update_lag(0);
111 gaim_signal_connect(handle, event_im_recv, check_lag, NULL); 111 gaim_signal_connect(handle, event_im_recv, check_lag, NULL);
112 gaim_signal_connect(handle, event_signoff, gaim_plugin_remove, NULL); 112 gaim_signal_connect(handle, event_signoff, gaim_plugin_remove, NULL);
113 check_timeout = gtk_timeout_add(1000 * delay, (GtkFunction)send_lag, NULL); 113 check_timeout = gtk_timeout_add(1000 * delay, (GtkFunction)send_lag, gc);
114 } 114 }
115 115
116 void gaim_plugin_init(void *h) { 116 void gaim_plugin_init(void *h) {
117 handle = h; 117 handle = h;
118 118
120 lagbox = NULL; 120 lagbox = NULL;
121 121
122 if (!blist) 122 if (!blist)
123 gaim_signal_connect(handle, event_signon, avail_now, NULL); 123 gaim_signal_connect(handle, event_signon, avail_now, NULL);
124 else 124 else
125 avail_now(NULL); 125 avail_now(connections->data, NULL);
126 } 126 }
127 127
128 void adjust_timeout(GtkWidget *button, GtkWidget *spinner) { 128 void adjust_timeout(GtkWidget *button, GtkWidget *spinner) {
129 delay = CLAMP(gtk_spin_button_get_value_as_int( 129 delay = CLAMP(gtk_spin_button_get_value_as_int(
130 GTK_SPIN_BUTTON(spinner)), 0, 3600); 130 GTK_SPIN_BUTTON(spinner)), 0, 3600);