changeset 12166:d6417efb990c

[gaim-migrate @ 14467] g_str_has_prefix is only available in glib >= 2.2.0. we already have a wrapper for this in gaim, but I guess it's not legitimate to use that in meanwhile, so I duplicated the wrapper there too. code reuse at it's worst. committer: Tailor Script <tailor@pidgin.im>
author Stu Tomlinson <stu@nosnilmot.com>
date Sat, 19 Nov 2005 18:09:51 +0000
parents f8e22fef03fc
children 5851a9219bc7
files src/protocols/sametime/meanwhile/mw_util.c src/protocols/sametime/meanwhile/mw_util.h src/protocols/sametime/meanwhile/srvc_im.c src/protocols/sametime/sametime.c
diffstat 4 files changed, 22 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/sametime/meanwhile/mw_util.c	Sat Nov 19 18:07:19 2005 +0000
+++ b/src/protocols/sametime/meanwhile/mw_util.c	Sat Nov 19 18:09:51 2005 +0000
@@ -78,3 +78,17 @@
   mw_datum_clear(d);
   g_free(d);
 }
+
+gboolean
+mw_str_has_prefix(const char *s, const char *p)
+{
+#if GLIB_CHECK_VERSION(2,2,0)
+	return g_str_has_prefix(s, p);
+#else
+	if (!strncmp(s, p, strlen(p)))
+		return TRUE;
+
+	return FALSE;
+#endif
+}
+
--- a/src/protocols/sametime/meanwhile/mw_util.h	Sat Nov 19 18:07:19 2005 +0000
+++ b/src/protocols/sametime/meanwhile/mw_util.h	Sat Nov 19 18:09:51 2005 +0000
@@ -21,7 +21,7 @@
 #ifndef _MW_UTIL_H
 #define _MW_UTIL_H
 
-
+#include <string.h>
 #include <glib.h>
 #include <glib/ghash.h>
 #include <glib/glist.h>
@@ -81,5 +81,6 @@
 
 void mw_datum_free(struct mw_datum *d);
 
+gboolean mw_str_has_prefix(const char *s, const char *p);
 
 #endif
--- a/src/protocols/sametime/meanwhile/srvc_im.c	Sat Nov 19 18:07:19 2005 +0000
+++ b/src/protocols/sametime/meanwhile/srvc_im.c	Sat Nov 19 18:09:51 2005 +0000
@@ -184,7 +184,7 @@
     c->features = srvc->features;
 
     /* mark external users */
-    c->ext_id = g_str_has_prefix(to->user, "@E ");
+    c->ext_id = mw_str_has_prefix(to->user, "@E ");
 
     srvc->convs = g_list_prepend(srvc->convs, c);
   }
--- a/src/protocols/sametime/sametime.c	Sat Nov 19 18:07:19 2005 +0000
+++ b/src/protocols/sametime/sametime.c	Sat Nov 19 18:09:51 2005 +0000
@@ -717,7 +717,7 @@
 
 static gboolean buddy_is_external(GaimBuddy *b) {
   g_return_val_if_fail(b != NULL, FALSE);
-  return g_str_has_prefix(b->name, "@E ");
+  return gaim_str_has_prefix(b->name, "@E ");
 }
 
 
@@ -2658,7 +2658,7 @@
     if(! type) {
       ; /* feh */
       
-    } else if(g_str_has_prefix(type, "image")) {
+    } else if(gaim_str_has_prefix(type, "image")) {
       /* put images into the image store */
 
       guchar *d_dat;
@@ -2683,7 +2683,7 @@
       /* recall the image for dereferencing later */
       images = g_list_append(images, GINT_TO_POINTER(img));
       
-    } else if(g_str_has_prefix(type, "text")) {
+    } else if(gaim_str_has_prefix(type, "text")) {
 
       /* concatenate all the text parts together */
       guchar *data;
@@ -4040,7 +4040,7 @@
 
   str = g_string_new(NULL);
 
-  if(g_str_has_prefix(who, "@E ")) {
+  if(gaim_str_has_prefix(who, "@E ")) {
     g_string_append(str, _("<b>External User</b><br>"));
   }
 
@@ -4452,7 +4452,7 @@
   srvc = pd->srvc_resolve;
 
   /* catch external buddies. They won't be in the resolve service */
-  if(g_str_has_prefix(buddy->name, "@E ")) {
+  if(gaim_str_has_prefix(buddy->name, "@E ")) {
     buddy_add(pd, buddy);
     return;
   }