equal
deleted
inserted
replaced
38 extern enum imstatus mystatus; |
38 extern enum imstatus mystatus; |
39 extern gchar *mystatusmsg; |
39 extern gchar *mystatusmsg; |
40 |
40 |
41 static GSList *invitations = NULL; |
41 static GSList *invitations = NULL; |
42 |
42 |
43 static void decline_invitation(event_muc_invitation *invitation, const char *reason) |
43 static void decline_invitation(event_muc_invitation_t *invitation, const char *reason) |
44 { |
44 { |
45 // cut and paste from xmpp_room_invite |
45 // cut and paste from xmpp_room_invite |
46 LmMessage *m; |
46 LmMessage *m; |
47 LmMessageNode *x, *y; |
47 LmMessageNode *x, *y; |
48 |
48 |
62 |
62 |
63 lm_connection_send(lconnection, m, NULL); |
63 lm_connection_send(lconnection, m, NULL); |
64 lm_message_unref(m); |
64 lm_message_unref(m); |
65 } |
65 } |
66 |
66 |
67 void destroy_event_muc_invitation(event_muc_invitation *invitation) |
67 void destroy_event_muc_invitation(event_muc_invitation_t *invitation) |
68 { |
68 { |
69 invitations = g_slist_remove(invitations, invitation); |
69 invitations = g_slist_remove(invitations, invitation); |
70 g_free(invitation->to); |
70 g_free(invitation->to); |
71 g_free(invitation->from); |
71 g_free(invitation->from); |
72 g_free(invitation->passwd); |
72 g_free(invitation->passwd); |
78 // invitation event handler |
78 // invitation event handler |
79 // TODO: if event is accepted, check if other events to the same room exist and |
79 // TODO: if event is accepted, check if other events to the same room exist and |
80 // destroy them? (need invitation registry list for that) |
80 // destroy them? (need invitation registry list for that) |
81 static gboolean evscallback_invitation(guint evcontext, const char *arg, gpointer userdata) |
81 static gboolean evscallback_invitation(guint evcontext, const char *arg, gpointer userdata) |
82 { |
82 { |
83 event_muc_invitation *invitation = userdata; |
83 event_muc_invitation_t *invitation = userdata; |
84 |
84 |
85 // Sanity check |
85 // Sanity check |
86 if (G_UNLIKELY(!invitation)) { |
86 if (G_UNLIKELY(!invitation)) { |
87 // Shouldn't happen. |
87 // Shouldn't happen. |
88 scr_LogPrint(LPRINT_LOGNORM, "Error in evs callback."); |
88 scr_LogPrint(LPRINT_LOGNORM, "Error in evs callback."); |
797 scr_LogPrint(LPRINT_LOGNORM, "%s", sbuf->str); |
797 scr_LogPrint(LPRINT_LOGNORM, "%s", sbuf->str); |
798 |
798 |
799 { // remove any equal older invites |
799 { // remove any equal older invites |
800 GSList *iel = invitations; |
800 GSList *iel = invitations; |
801 while (iel) { |
801 while (iel) { |
802 event_muc_invitation *invitation = iel->data; |
802 event_muc_invitation_t *invitation = iel->data; |
803 iel = iel -> next; |
803 iel = iel -> next; |
804 if (!g_strcmp0(to, invitation->to) && |
804 if (!g_strcmp0(to, invitation->to) && |
805 !g_strcmp0(passwd, invitation->passwd)) { |
805 !g_strcmp0(passwd, invitation->passwd)) { |
806 // found a previous invitation |
806 // found a previous invitation |
807 // We keep the old one, unless the current one is better and allows us |
807 // We keep the old one, unless the current one is better and allows us |
818 } |
818 } |
819 |
819 |
820 { // create event |
820 { // create event |
821 const char *id; |
821 const char *id; |
822 char *desc = g_strdup_printf("<%s> invites you to %s", from, to); |
822 char *desc = g_strdup_printf("<%s> invites you to %s", from, to); |
823 event_muc_invitation *invitation; |
823 event_muc_invitation_t *invitation; |
824 |
824 |
825 invitation = g_new(event_muc_invitation, 1); |
825 invitation = g_new(event_muc_invitation_t, 1); |
826 invitation->to = g_strdup(to); |
826 invitation->to = g_strdup(to); |
827 invitation->from = g_strdup(from); |
827 invitation->from = g_strdup(from); |
828 invitation->passwd = g_strdup(passwd); |
828 invitation->passwd = g_strdup(passwd); |
829 invitation->reason = g_strdup(reason); |
829 invitation->reason = g_strdup(reason); |
830 invitation->reply = reply; |
830 invitation->reply = reply; |