jingle/check.c
changeset 32 72bbe33f151a
parent 29 9215053e8fb0
child 58 daafe5b8a48d
equal deleted inserted replaced
31:02f5698ffa49 32:72bbe33f151a
   103 {
   103 {
   104   JingleContent *cn = g_new0(JingleContent, 1);
   104   JingleContent *cn = g_new0(JingleContent, 1);
   105   const gchar *creatorstr, *sendersstr;
   105   const gchar *creatorstr, *sendersstr;
   106   gint tmp, tmp2;
   106   gint tmp, tmp2;
   107   LmMessageNode *tmpnode = NULL;
   107   LmMessageNode *tmpnode = NULL;
   108   
   108 
   109   creatorstr      = lm_message_node_get_attribute(node, "creator");
   109   creatorstr      = lm_message_node_get_attribute(node, "creator");
   110   cn->disposition = lm_message_node_get_attribute(node, "disposition");
   110   cn->disposition = lm_message_node_get_attribute(node, "disposition");
   111   cn->name        = lm_message_node_get_attribute(node, "name");
   111   cn->name        = lm_message_node_get_attribute(node, "name");
   112   sendersstr      = lm_message_node_get_attribute(node, "senders");
   112   sendersstr      = lm_message_node_get_attribute(node, "senders");
   113 
   113 
   115     g_set_error(err, JINGLE_CHECK_ERROR, JINGLE_CHECK_ERROR_MISSING,
   115     g_set_error(err, JINGLE_CHECK_ERROR, JINGLE_CHECK_ERROR_MISSING,
   116                 "an attribute of the content element is missing");
   116                 "an attribute of the content element is missing");
   117     g_free(cn);
   117     g_free(cn);
   118     return NULL;
   118     return NULL;
   119   }
   119   }
   120   
   120 
   121   tmp = index_in_array(creatorstr, jingle_content_creator);
   121   tmp = index_in_array(creatorstr, jingle_content_creator);
   122   tmp2 = index_in_array(sendersstr, jingle_content_senders);
   122   tmp2 = index_in_array(sendersstr, jingle_content_senders);
   123   if (tmp < 0 || tmp2 < 0) {
   123   if (tmp < 0 || tmp2 < 0) {
   124     g_set_error(err, JINGLE_CHECK_ERROR, JINGLE_CHECK_ERROR_BADVALUE,
   124     g_set_error(err, JINGLE_CHECK_ERROR, JINGLE_CHECK_ERROR_BADVALUE,
   125                 "the attribute creator or sender is invalid");
   125                 "the attribute creator or sender is invalid");
   126     g_free(cn);
   126     g_free(cn);
   127     return NULL;
   127     return NULL;
   128   }
   128   }
   129   cn->creator = (JingleCreator)tmp;
   129   cn->creator = (JingleCreator)tmp;
   130   cn->senders = (JingleSenders)tmp2;
   130   cn->senders = (JingleSenders)tmp2;
   131   
       
   132   tmpnode = lm_message_node_get_child(node, "description");
       
   133   if(tmpnode == NULL) {
       
   134     g_set_error(err, JINGLE_CHECK_ERROR, JINGLE_CHECK_ERROR_MISSING,
       
   135                 "a child element of content is missing");
       
   136     g_free(cn);
       
   137     return NULL;
       
   138   }
       
   139   
       
   140   cn->xmlns_desc = lm_message_node_get_attribute(tmpnode, "xmlns");
       
   141   
       
   142   tmpnode = lm_message_node_get_child(node, "transport");
       
   143   if (tmpnode == NULL) {
       
   144     g_set_error(err, JINGLE_CHECK_ERROR, JINGLE_CHECK_ERROR_MISSING,
       
   145                 "a child element of content is missing");
       
   146     g_free(cn);
       
   147     return NULL;
       
   148   }
       
   149 
   131 
   150   cn->xmlns_trans = lm_message_node_get_attribute(tmpnode, "xmlns");
   132   cn->description = lm_message_node_get_child(node, "description");
   151   
   133   cn->transport   = lm_message_node_get_child(node, "transport");
       
   134   if (cn->description == NULL || cn->transport == NULL) {
       
   135      g_set_error(err, JINGLE_CHECK_ERROR, JINGLE_CHECK_ERROR_MISSING,
       
   136                  "a child element of content is missing");
       
   137      g_free(cn);
       
   138      return NULL;
       
   139    }
       
   140 
   152   return cn;
   141   return cn;
   153 }
   142 }
   154 
   143 
   155 /**
   144 /**
   156  * Check <content> elements if there is any.
   145  * Check <content> elements if there is any.