jingle/sessions.c
changeset 31 02f5698ffa49
parent 24 c80439433dd7
child 32 72bbe33f151a
equal deleted inserted replaced
30:8c3a03e08fd8 31:02f5698ffa49
    38   JingleSession *js = g_new0(JingleSession, 1);
    38   JingleSession *js = g_new0(JingleSession, 1);
    39   const gchar *from;
    39   const gchar *from;
    40   
    40   
    41   js->sid = g_strdup(jn->sid);
    41   js->sid = g_strdup(jn->sid);
    42   js->initiator = g_strdup(jn->initiator);
    42   js->initiator = g_strdup(jn->initiator);
    43   from = lm_message_node_get_attribute(lm_message_get_node(jn->message),
    43   from = lm_message_node_get_attribute(lm_message_get_node(jn->message), "from");
    44                                        "from");
       
    45   if (!from) {
    44   if (!from) {
    46     return NULL;
    45     return NULL;
    47   }
    46   }
    48   js->from = g_strdup(from);
    47   js->from = g_strdup(from);
    49   
    48   
    50 
    49 
    51   sessions = g_slist_append(sessions, js);
    50   sessions = g_slist_append(sessions, js);
    52 }
    51 }
    53 
    52 
    54 JingleSession *session_find(const gchar *sid, const gchar *from)
    53 JingleSession *session_find_by_sid(const gchar *sid, const gchar *from)
    55 {
    54 {
    56   GSList *el;
    55   GSList *el;
    57   JingleSession *js;
    56   JingleSession *js;
    58   for (el = sessions; el; el = el->next) {
    57   for (el = sessions; el; el = el->next) {
    59     js = (JingleSession*) el->data;
    58     js = (JingleSession*) el->data;
    60     if (g_strcmp0(js->sid, sid) && g_strcmp0(js->from, from)) {
    59     if (g_strcmp0(js->sid, sid) && g_strcmp0(js->from, from)) {
    61       return js;
    60       return js;
    62 	}
    61 	}
    63   }
    62   }
    64   return NULL;
    63   return NULL;
       
    64 }
       
    65 
       
    66 JingleSession *session_find(const JingleNode *jn)
       
    67 {
       
    68   LmMessageNode *iq = lm_message_get_node(jn->message);
       
    69   const gchar *from = lm_message_node_get_attribute(iq, "from");
       
    70   return session_find_by_sid(jn->sid, from);
    65 }
    71 }
    66 
    72 
    67 /**
    73 /**
    68  * Remove a session from the linked list and free it.
    74  * Remove a session from the linked list and free it.
    69  */
    75  */