| 143 jabber_add_feature("mood", "http://jabber.org/protocol/mood", jabber_pep_namespace_only_when_pep_enabled_cb); |
144 jabber_add_feature("mood", "http://jabber.org/protocol/mood", jabber_pep_namespace_only_when_pep_enabled_cb); |
| 144 jabber_pep_register_handler("moodn", "http://jabber.org/protocol/mood", jabber_mood_cb); |
145 jabber_pep_register_handler("moodn", "http://jabber.org/protocol/mood", jabber_mood_cb); |
| 145 } |
146 } |
| 146 |
147 |
| 147 static void do_mood_set_from_fields(PurpleConnection *gc, PurpleRequestFields *fields) { |
148 static void do_mood_set_from_fields(PurpleConnection *gc, PurpleRequestFields *fields) { |
| 148 JabberStream *js = gc->proto_data; |
149 JabberStream *js; |
| 149 |
150 int max_mood_idx; |
| 150 jabber_mood_set(js, moodstrings[purple_request_fields_get_choice(fields, "mood")], purple_request_fields_get_string(fields, "text")); |
151 int selected_mood = purple_request_fields_get_choice(fields, "mood"); |
| |
152 |
| |
153 if (!PURPLE_CONNECTION_IS_VALID(gc)) { |
| |
154 purple_debug_error("jabber", "Unable to set mood; account offline.\n"); |
| |
155 return; |
| |
156 } |
| |
157 |
| |
158 js = gc->proto_data; |
| |
159 |
| |
160 /* This is ugly, but protects us from unexpected values. */ |
| |
161 for (max_mood_idx = 0; moodstrings[max_mood_idx]; max_mood_idx++); |
| |
162 |
| |
163 if (selected_mood < 0 || selected_mood >= max_mood_idx) { |
| |
164 purple_debug_error("jabber", "Invalid mood index (%d) selected.\n", selected_mood); |
| |
165 return; |
| |
166 } |
| |
167 |
| |
168 jabber_mood_set(js, moodstrings[selected_mood], purple_request_fields_get_string(fields, "text")); |
| 151 } |
169 } |
| 152 |
170 |
| 153 static void do_mood_set_mood(PurplePluginAction *action) { |
171 static void do_mood_set_mood(PurplePluginAction *action) { |
| 154 PurpleConnection *gc = (PurpleConnection *) action->context; |
172 PurpleConnection *gc = (PurpleConnection *) action->context; |
| 155 |
173 |