pidgin/pidginconversation.c

changeset 43058
7b3b26faf6ed
parent 42905
d332eb539cb9
child 43072
a59a119b74f5
equal deleted inserted replaced
43057:2c801eae5449 43058:7b3b26faf6ed
138 PurpleMessage *message = NULL; 138 PurpleMessage *message = NULL;
139 GtkTextBuffer *buffer = NULL; 139 GtkTextBuffer *buffer = NULL;
140 GtkTextIter start; 140 GtkTextIter start;
141 GtkTextIter end; 141 GtkTextIter end;
142 char *contents = NULL; 142 char *contents = NULL;
143 gboolean command_executed = FALSE;
143 144
144 account = purple_conversation_get_account(conversation->conversation); 145 account = purple_conversation_get_account(conversation->conversation);
145 146
146 /* Get the contents from the buffer. */ 147 /* Get the contents from the buffer. */
147 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(conversation->input)); 148 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(conversation->input));
148 gtk_text_buffer_get_start_iter(buffer, &start); 149 gtk_text_buffer_get_start_iter(buffer, &start);
149 gtk_text_buffer_get_end_iter(buffer, &end); 150 gtk_text_buffer_get_end_iter(buffer, &end);
150 151
151 contents = gtk_text_buffer_get_text(buffer, &start, &end, TRUE); 152 contents = gtk_text_buffer_get_text(buffer, &start, &end, TRUE);
152 153
153 /* Create the message. */ 154 if(contents != NULL && contents[0] == '/') {
154 info = purple_account_get_contact_info(account); 155 PurpleCommandManager *manager = NULL;
155 message = purple_message_new(info, contents); 156
156 157 manager = purple_command_manager_get_default();
157 /* Send the message and clean up. We don't worry about the callback as we 158 command_executed = purple_command_manager_find_and_execute(manager,
158 * don't have anything to do in it right now. 159 conversation->conversation,
159 */ 160 contents + 1);
160 purple_conversation_send_message_async(conversation->conversation, message, 161 }
161 NULL, NULL, NULL); 162
162 163 if(!command_executed) {
163 g_clear_object(&message); 164 /* Create the message. */
165 info = purple_account_get_contact_info(account);
166 message = purple_message_new(info, contents);
167
168 /* Send the message and clean up. We don't worry about the callback as we
169 * don't have anything to do in it right now.
170 */
171 purple_conversation_send_message_async(conversation->conversation, message,
172 NULL, NULL, NULL);
173
174 g_clear_object(&message);
175 }
176
164 g_clear_pointer(&contents, g_free); 177 g_clear_pointer(&contents, g_free);
165 178
166 gtk_text_buffer_set_text(buffer, "", -1); 179 gtk_text_buffer_set_text(buffer, "", -1);
167 } 180 }
168 181

mercurial