6 * Copyright (C) 2009 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
29 #include "sipe-utils.h"
31 /* Generate 32 random bits */
32 #define RANDOM32BITS (rand() & 0xFFFF)
34 gchar
*gencallid(void)
36 return g_strdup_printf("%04Xg%04Xa%04Xi%04Xm%04Xt%04Xb%04Xx%04Xx",
37 RANDOM32BITS
, RANDOM32BITS
, RANDOM32BITS
,
38 RANDOM32BITS
, RANDOM32BITS
, RANDOM32BITS
,
39 RANDOM32BITS
, RANDOM32BITS
);
44 return g_strdup_printf("%04d%04d", RANDOM32BITS
, RANDOM32BITS
);
47 gchar
*get_contact(const struct sipe_account_data
*sip
)
49 return g_strdup(sip
->contact
);
52 gchar
*parse_from(const gchar
*hdr
)
55 const gchar
*tmp
, *tmp2
= hdr
;
57 if (!hdr
) return NULL
;
58 purple_debug_info("sipe", "parsing address out of %s\n", hdr
);
59 tmp
= strchr(hdr
, '<');
61 /* i hate the different SIP UA behaviours... */
62 if (tmp
) { /* sip address in <...> */
64 tmp
= strchr(tmp2
, '>');
66 from
= g_strndup(tmp2
, tmp
- tmp2
);
68 purple_debug_info("sipe", "found < without > in From\n");
72 tmp
= strchr(tmp2
, ';');
74 from
= g_strndup(tmp2
, tmp
- tmp2
);
76 from
= g_strdup(tmp2
);
79 purple_debug_info("sipe", "got %s\n", from
);