jingle/jingle.c
changeset 79 a654afc4a74a
parent 77 56c6ab96026f
child 80 1c2ef2c5debe
equal deleted inserted replaced
78:0b138243bd4a 79:a654afc4a74a
   272     lm_connection_send(lconnection, r, NULL);
   272     lm_connection_send(lconnection, r, NULL);
   273   }
   273   }
   274 }
   274 }
   275 
   275 
   276 /**
   276 /**
       
   277  * Find the best resource to initiate a jingle session.
       
   278  * Test every ressource for a given jid and return the one
       
   279  * who support all namespaces in ns.
       
   280  */
       
   281 gchar *jingle_find_compatible_res(const gchar *jid, const gchar *ns[])
       
   282 {
       
   283   gchar *choosenres;
       
   284   guint indexns;
       
   285   gboolean found;
       
   286   GList *roster_usr;
       
   287   GSList *reslist, *thisres;
       
   288 
       
   289   roster_usr = buddy_search_jid(jid);
       
   290   reslist = buddy_getresources(roster_usr->data);
       
   291   for (thisres = reslist; thisres; thisres = g_slist_next(thisres)) {
       
   292     found = TRUE;
       
   293     for (indexns = 0; ns[indexns]; indexns++) {
       
   294 	  if (!caps_has_feature(buddy_resource_getcaps(roster_usr->data, thisres->data), ns[indexns]))
       
   295 	    found = FALSE;
       
   296 	}
       
   297 	if (!found) continue;
       
   298 
       
   299     choosenres = g_strdup(thisres->data);
       
   300     g_slist_foreach(reslist, (GFunc)g_free, NULL);
       
   301     g_slist_free(reslist);
       
   302     return choosenres;
       
   303   }
       
   304 }
       
   305 
       
   306 /**
   277  * Find the jingle_action corresponding to a string
   307  * Find the jingle_action corresponding to a string
   278  */
   308  */
   279 JingleAction jingle_action_from_str(const gchar *string)
   309 JingleAction jingle_action_from_str(const gchar *string)
   280 {
   310 {
   281   guint i, actstrlen = sizeof(jingle_action_list)/sizeof(jingle_action_list[0]);
   311   guint i, actstrlen = sizeof(jingle_action_list)/sizeof(jingle_action_list[0]);
   474     return;  
   504     return;  
   475   }
   505   }
   476   sc->appfuncs->handle_data(sc->description, data2, len);
   506   sc->appfuncs->handle_data(sc->description, data2, len);
   477 }
   507 }
   478 
   508 
   479 gchar *new_sid(void)
   509 gchar *jingle_generate_sid(void)
   480 {
   510 {
   481   gchar *sid;
   511   gchar *sid;
   482   gchar car[] = "azertyuiopqsdfghjklmwxcvbn1234567890AZERTYUIOPQSDFGHJKLMWXCVBN";
   512   gchar car[] = "azertyuiopqsdfghjklmwxcvbn1234567890AZERTYUIOPQSDFGHJKLMWXCVBN";
   483   int i;
   513   int i;
   484   sid = g_new0(gchar, 11);
   514   sid = g_new0(gchar, 11);