comparison mcabber/src/jabglue.c @ 116:1e7e59775f12

[/trunk] Changeset 130 by mikael * Add /status command. * Fix /quit command when there is a trailing word ("/quit bye"...). * Add an extension (.txt) to the TODO file.
author mikael
date Mon, 25 Apr 2005 15:26:17 +0000
parents 065d8368c36b
children 1e8f646e2c5b
comparison
equal deleted inserted replaced
115:33bff2c57293 116:1e7e59775f12
34 jconn jc; 34 jconn jc;
35 time_t LastPingTime; 35 time_t LastPingTime;
36 unsigned int KeepaliveDelay; 36 unsigned int KeepaliveDelay;
37 static int s_id = 1; // FIXME which use?? 37 static int s_id = 1; // FIXME which use??
38 static int regmode, regdone; 38 static int regmode, regdone;
39 static enum imstatus mystatus = offline;
39 unsigned char online; 40 unsigned char online;
40 41
41 char imstatus2char[imstatus_size] = { 42 char imstatus2char[imstatus_size] = {
42 '_', 'o', 'i', 'f', 'd', 'c', 'n', 'a' 43 '_', 'o', 'i', 'f', 'd', 'c', 'n', 'a'
43 }; 44 };
201 if (now > LastPingTime + KeepaliveDelay) 202 if (now > LastPingTime + KeepaliveDelay)
202 jb_keepalive(); 203 jb_keepalive();
203 } 204 }
204 } 205 }
205 206
206 void setjabberstatus(enum imstatus st, char *msg) 207 inline enum imstatus jb_getstatus()
207 { 208 {
208 xmlnode x = jutil_presnew(JPACKET__UNKNOWN, 0, 0); 209 return mystatus;
210 }
211
212 void jb_setstatus(enum imstatus st, char *msg)
213 {
214 xmlnode x;
215
216 if (!online)
217 return;
218
219 x = jutil_presnew(JPACKET__UNKNOWN, 0, 0);
209 220
210 switch(st) { 221 switch(st) {
211 case away: 222 case away:
212 xmlnode_insert_cdata(xmlnode_insert_tag(x, "show"), "away", 223 xmlnode_insert_cdata(xmlnode_insert_tag(x, "show"), "away",
213 (unsigned) -1); 224 (unsigned) -1);
241 if (!add["prio"].empty()) 252 if (!add["prio"].empty())
242 xmlnode_insert_cdata(xmlnode_insert_tag(x, "priority"), 253 xmlnode_insert_cdata(xmlnode_insert_tag(x, "priority"),
243 add["prio"].c_str(), (unsigned) -1); 254 add["prio"].c_str(), (unsigned) -1);
244 */ 255 */
245 256
246 if (!msg || !*msg) { 257 if (!msg) {
247 msg = ""; // FIXME 258 msg = ""; // FIXME
248 //msg = imstatus2str(st); 259 //msg = imstatus2str(st);
249 } 260 }
250 261
251 xmlnode_insert_cdata(xmlnode_insert_tag(x, "status"), msg, 262 xmlnode_insert_cdata(xmlnode_insert_tag(x, "status"), msg,
252 (unsigned) -1); 263 (unsigned) -1);
253 264
254 jab_send(jc, x); 265 jab_send(jc, x);
255 xmlnode_free(x); 266 xmlnode_free(x);
256 267
257 //sendvisibility(); 268 //sendvisibility(); ???
258 269
259 // XXX logger.putourstatus(proto, getstatus(), ourstatus = st); 270 hk_mystatuschange(0, mystatus, st);
271 mystatus = st;
260 } 272 }
261 273
262 void jb_send_msg(const char *jid, const char *text) 274 void jb_send_msg(const char *jid, const char *text)
263 { 275 {
264 xmlnode x = jutil_msgnew(TMSG_CHAT, (char*)jid, 0, (char*)text); 276 xmlnode x = jutil_msgnew(TMSG_CHAT, (char*)jid, 0, (char*)text);
274 //flogged = TRUE; 286 //flogged = TRUE;
275 //ourstatus = available; 287 //ourstatus = available;
276 288
277 //setautostatus(jhook.manualstatus); 289 //setautostatus(jhook.manualstatus);
278 290
279 setjabberstatus(1, "I'm here!"); 291 jb_setstatus(available, "I'm here!"); // XXX not always "available"...
280 buddylist_build(); 292 buddylist_build();
281 /* 293 /*
282 for (i = 0; i < clist.count; i++) { 294 for (i = 0; i < clist.count; i++) {
283 c = (icqcontact *) clist.at(i); 295 c = (icqcontact *) clist.at(i);
284 296