Mercurial > pidgin.yaz
comparison libgaim/protocols/irc/irc.c @ 14621:bf1f941575be
[gaim-migrate @ 17350]
IRC signals for scripting IRC.
Richard, you should use these for irchelper!
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Mon, 25 Sep 2006 21:08:39 +0000 |
parents | 8ed6ef220b2d |
children | f8beee12ade9 |
comparison
equal
deleted
inserted
replaced
14620:a426f0945575 | 14621:bf1f941575be |
---|---|
59 | 59 |
60 static guint irc_nick_hash(const char *nick); | 60 static guint irc_nick_hash(const char *nick); |
61 static gboolean irc_nick_equal(const char *nick1, const char *nick2); | 61 static gboolean irc_nick_equal(const char *nick1, const char *nick2); |
62 static void irc_buddy_free(struct irc_buddy *ib); | 62 static void irc_buddy_free(struct irc_buddy *ib); |
63 | 63 |
64 static GaimPlugin *_irc_plugin = NULL; | 64 GaimPlugin *_irc_plugin = NULL; |
65 | 65 |
66 static const char *status_chars = "@+%&"; | 66 static const char *status_chars = "@+%&"; |
67 | 67 |
68 static void irc_view_motd(GaimPluginAction *action) | 68 static void irc_view_motd(GaimPluginAction *action) |
69 { | 69 { |
139 #endif | 139 #endif |
140 } | 140 } |
141 | 141 |
142 int irc_send(struct irc_conn *irc, const char *buf) | 142 int irc_send(struct irc_conn *irc, const char *buf) |
143 { | 143 { |
144 int ret, buflen = strlen(buf); | 144 int ret, buflen; |
145 | 145 char *tosend= g_strdup(buf); |
146 | |
147 gaim_signal_emit(_irc_plugin, "irc-sending_text", gaim_account_get_connection(irc->account), &tosend); | |
148 if (tosend == NULL) | |
149 return 0; | |
150 | |
151 buflen = strlen(tosend); | |
152 | |
153 | |
146 /* If we're not buffering writes, try to send immediately */ | 154 /* If we're not buffering writes, try to send immediately */ |
147 if (!irc->writeh) | 155 if (!irc->writeh) |
148 ret = do_send(irc, buf, buflen); | 156 ret = do_send(irc, tosend, buflen); |
149 else { | 157 else { |
150 ret = -1; | 158 ret = -1; |
151 errno = EAGAIN; | 159 errno = EAGAIN; |
152 } | 160 } |
153 | 161 |
154 /* gaim_debug(GAIM_DEBUG_MISC, "irc", "sent%s: %s", | 162 /* gaim_debug(GAIM_DEBUG_MISC, "irc", "sent%s: %s", |
155 irc->gsc ? " (ssl)" : "", buf); */ | 163 irc->gsc ? " (ssl)" : "", tosend); */ |
156 if (ret <= 0 && errno != EAGAIN) { | 164 if (ret <= 0 && errno != EAGAIN) { |
157 gaim_connection_error(gaim_account_get_connection(irc->account), | 165 gaim_connection_error(gaim_account_get_connection(irc->account), |
158 _("Server has disconnected")); | 166 _("Server has disconnected")); |
159 } else if (ret < buflen) { | 167 } else if (ret < buflen) { |
160 if (ret < 0) | 168 if (ret < 0) |
161 ret = 0; | 169 ret = 0; |
162 if (!irc->writeh) | 170 if (!irc->writeh) |
163 irc->writeh = gaim_input_add( | 171 irc->writeh = gaim_input_add( |
164 irc->gsc ? irc->gsc->fd : irc->fd, | 172 irc->gsc ? irc->gsc->fd : irc->fd, |
165 GAIM_INPUT_WRITE, irc_send_cb, irc); | 173 GAIM_INPUT_WRITE, irc_send_cb, irc); |
166 gaim_circ_buffer_append(irc->outbuf, buf + ret, | 174 gaim_circ_buffer_append(irc->outbuf, tosend + ret, |
167 buflen - ret); | 175 buflen - ret); |
168 } | 176 } |
169 | 177 g_free(tosend); |
170 return ret; | 178 return ret; |
171 } | 179 } |
172 | 180 |
173 /* XXX I don't like messing directly with these buddies */ | 181 /* XXX I don't like messing directly with these buddies */ |
174 gboolean irc_blist_timeout(struct irc_conn *irc) | 182 gboolean irc_blist_timeout(struct irc_conn *irc) |
867 NULL, /* offline_message */ | 875 NULL, /* offline_message */ |
868 NULL, /* whiteboard_prpl_ops */ | 876 NULL, /* whiteboard_prpl_ops */ |
869 irc_send_raw, /* send_raw */ | 877 irc_send_raw, /* send_raw */ |
870 }; | 878 }; |
871 | 879 |
880 static gboolean load_plugin (GaimPlugin *plugin) { | |
881 | |
882 gaim_signal_register(plugin, "irc-sending-text", | |
883 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, | |
884 gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_CONNECTION), | |
885 gaim_value_new_outgoing(GAIM_TYPE_STRING)); | |
886 gaim_signal_register(plugin, "irc-receiving-text", | |
887 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, | |
888 gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_CONNECTION), | |
889 gaim_value_new_outgoing(GAIM_TYPE_STRING)); | |
890 return TRUE; | |
891 } | |
892 | |
872 | 893 |
873 static GaimPluginInfo info = | 894 static GaimPluginInfo info = |
874 { | 895 { |
875 GAIM_PLUGIN_MAGIC, | 896 GAIM_PLUGIN_MAGIC, |
876 GAIM_MAJOR_VERSION, | 897 GAIM_MAJOR_VERSION, |
887 N_("IRC Protocol Plugin"), /** summary */ | 908 N_("IRC Protocol Plugin"), /** summary */ |
888 N_("The IRC Protocol Plugin that Sucks Less"), /** description */ | 909 N_("The IRC Protocol Plugin that Sucks Less"), /** description */ |
889 NULL, /**< author */ | 910 NULL, /**< author */ |
890 GAIM_WEBSITE, /**< homepage */ | 911 GAIM_WEBSITE, /**< homepage */ |
891 | 912 |
892 NULL, /**< load */ | 913 load_plugin, /**< load */ |
893 NULL, /**< unload */ | 914 NULL, /**< unload */ |
894 NULL, /**< destroy */ | 915 NULL, /**< destroy */ |
895 | 916 |
896 NULL, /**< ui_info */ | 917 NULL, /**< ui_info */ |
897 &prpl_info, /**< extra_info */ | 918 &prpl_info, /**< extra_info */ |