~ampelbein/+junk/fix-1201213

« back to all changes in this revision

Viewing changes to src/jab_iq.c

  • Committer: Bazaar Package Importer
  • Author(s): Gerfried Fuchs
  • Date: 2009-10-08 19:37:25 UTC
  • mto: (1.1.7 upstream) (3.1.3 squeeze)
  • mto: This revision was merged to the branch mainline in revision 10.
  • Revision ID: james.westby@ubuntu.com-20091008193725-m04qzt6mv82hb7ho
ImportĀ upstreamĀ versionĀ 0.9.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
 
70
70
typedef void (*adhoc_command_callback)(jconn, char*, const char*, xmlnode);
71
71
 
 
72
inline double seconds_since_last_use(void);
 
73
 
72
74
struct adhoc_command {
73
75
  char *name;
74
76
  char *description;
1188
1190
    // I do not think this is useful, user should not have to care of the
1189
1191
    // priority like gossip and gajim do (misc)
1190
1192
    y = xmlnode_insert_tag(x, "field");
1191
 
    xmlnode_put_attrib(y, "type", "text-multi");
 
1193
    xmlnode_put_attrib(y, "type", "text-single");
1192
1194
    xmlnode_put_attrib(y, "var", "status-message");
1193
1195
    xmlnode_put_attrib(y, "label", "Message");
1194
 
  } else if (!strcmp(action, "cancel")) {
 
1196
  } else if (action && !strcmp(action, "cancel")) {
1195
1197
    xmlnode_put_attrib(command, "status", "canceled");
1196
1198
  } else  { // (if sessionid and not canceled)
1197
1199
    y = xmlnode_get_tag(x, "x?xmlns=jabber:x:data");
1201
1203
                                   "value");
1202
1204
      message = xmlnode_get_tag_data(xmlnode_get_tag(y,
1203
1205
                                   "field?var=status-message"), "value");
1204
 
      for (s = adhoc_status_list; !s->name || strcmp(s->name, value); s++);
1205
 
      if (s->name) {
1206
 
        char *status = g_strdup_printf("%s %s", s->status,
1207
 
                                       message ? message : "");
1208
 
        cmd_setstatus(NULL, status);
1209
 
        g_free(status);
1210
 
        xmlnode_put_attrib(command, "status", "completed");
1211
 
        xmlnode_put_attrib(iq, "type", "result");
1212
 
        xmlnode_insert_dataform_result_message(command,
1213
 
                                               "Status has been changed");
 
1206
      if (value) {
 
1207
        for (s = adhoc_status_list; s->name && strcmp(s->name, value); s++);
 
1208
        if (s->name) {
 
1209
          char *status = g_strdup_printf("%s %s", s->status,
 
1210
                                         message ? message : "");
 
1211
          cmd_setstatus(NULL, status);
 
1212
          g_free(status);
 
1213
          xmlnode_put_attrib(command, "status", "completed");
 
1214
          xmlnode_put_attrib(iq, "type", "result");
 
1215
          xmlnode_insert_dataform_result_message(command,
 
1216
                                                 "Status has been changed");
 
1217
        }
1214
1218
      }
1215
1219
    }
1216
1220
  }
1293
1297
    xmlnode_insert_tag(field, "required");
1294
1298
 
1295
1299
    foreach_buddy(ROSTER_TYPE_ROOM, &_callback_foreach_buddy_groupchat, &field);
1296
 
  } else if (!strcmp(action, "cancel")) {
 
1300
  } else if (action && !strcmp(action, "cancel")) {
1297
1301
    xmlnode_put_attrib(command, "status", "canceled");
1298
1302
  } else  { // (if sessionid and not canceled)
1299
1303
    xmlnode form = xmlnode_get_tag(x, "x?xmlns=jabber:x:data");
1468
1472
  xmlnode_free(x);
1469
1473
}
1470
1474
 
1471
 
inline double seconds_since_last_use(void)
 
1475
double seconds_since_last_use(void)
1472
1476
{
1473
1477
  return difftime(time(NULL), iqlast);
1474
1478
}