mingw: add missing time.h include
[siplcs.git] / src / core / sipe-buddy.c
blob3b3a99aaa30043542a93ce067c8f6f604031cc73
1 /**
2 * @file sipe-buddy.c
4 * pidgin-sipe
6 * Copyright (C) 2010 SIPE Project <http://sipe.sourceforge.net/>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include <time.h>
25 #include <glib.h>
27 #include "sipe-buddy.h"
28 #include "sipe-core.h"
29 #include "sipe-core-private.h"
31 gchar *sipe_core_buddy_status(struct sipe_core_public *sipe_public,
32 const gchar *name,
33 const sipe_activity activity,
34 const gchar *status_text)
36 struct sipe_buddy *sbuddy;
37 const char *activity_str;
39 if (!sipe_public) return NULL; /* happens on pidgin exit */
41 sbuddy = g_hash_table_lookup(SIPE_CORE_PRIVATE->buddies, name);
42 if (!sbuddy) return NULL;
44 activity_str = sbuddy->activity ? sbuddy->activity :
45 (activity == SIPE_ACTIVITY_BUSY) || (activity == SIPE_ACTIVITY_BRB) ?
46 status_text : NULL;
48 if (activity_str && sbuddy->note) {
49 return g_strdup_printf("%s - <i>%s</i>", activity_str, sbuddy->note);
50 } else if (activity_str) {
51 return g_strdup(activity_str);
52 } else if (sbuddy->note) {
53 return g_strdup_printf("<i>%s</i>", sbuddy->note);
54 } else {
55 return NULL;
60 Local Variables:
61 mode: c
62 c-file-style: "bsd"
63 indent-tabs-mode: t
64 tab-width: 8
65 End: