Fix #3198585: Extra line breaks
[siplcs.git] / src / core / sipe-core.c
blobdeac4d77928d4dd54a3cce9c7b781db2cf8889fd
1 /**
2 * @file sipe-core.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 #ifdef HAVE_CONFIG_H
24 #include "config.h"
25 #endif
27 #include <stdlib.h>
29 #include <glib.h>
30 #ifdef HAVE_NSS
31 #include "nss.h"
32 #endif
33 #ifdef HAVE_GMIME
34 #include <gmime/gmime.h>
35 #endif
37 #include "sipe-common.h"
38 #include "sip-csta.h"
39 #include "sip-sec.h"
40 #include "sip-transport.h"
41 #include "sipe-backend.h"
42 #include "sipe-chat.h"
43 #include "sipe-core.h"
44 #include "sipe-core-private.h"
45 #include "sipe-nls.h"
46 #include "sipe-session.h"
47 #include "sipe-subscriptions.h"
48 #include "sipe-media.h"
49 #include "sipe.h"
51 /* locale_dir is unused if ENABLE_NLS is not defined */
52 void sipe_core_init(SIPE_UNUSED_PARAMETER const char *locale_dir)
54 srand(time(NULL));
55 sip_sec_init();
57 #ifdef ENABLE_NLS
58 SIPE_DEBUG_INFO("bindtextdomain = %s",
59 bindtextdomain(PACKAGE_NAME, locale_dir));
60 SIPE_DEBUG_INFO("bind_textdomain_codeset = %s",
61 bind_textdomain_codeset(PACKAGE_NAME, "UTF-8"));
62 textdomain(PACKAGE_NAME);
63 #endif
64 #ifdef HAVE_NSS
65 if (!NSS_IsInitialized()) {
66 NSS_NoDB_Init(".");
67 SIPE_DEBUG_INFO_NOFORMAT("NSS initialised");
69 #endif
70 #ifdef HAVE_GMIME
71 g_mime_init(0);
72 #endif
75 void sipe_core_destroy(void)
77 sipe_chat_destroy();
78 #ifdef HAVE_NSS
79 /* do nothing.
80 * We don't want accedently switch off NSS possibly used by other plugin -
81 * ssl-nss in Pidgin for example.
83 #endif
84 #ifdef HAVE_GMIME
85 g_mime_shutdown();
86 #endif
87 sip_sec_destroy();
90 gchar *sipe_core_about(void)
92 return g_strdup_printf(
94 * Non-translatable parts, like markup, are hard-coded
95 * into the format string. This requires more translatable
96 * texts but it makes the translations less error prone.
98 "<b><font size=\"+1\">SIPE " PACKAGE_VERSION " </font></b><br/>"
99 "<br/>"
100 /* 1 */ "%s:<br/>"
101 "<li> - MS Office Communications Server 2007 R2</li><br/>"
102 "<li> - MS Office Communications Server 2007</li><br/>"
103 "<li> - MS Live Communications Server 2005</li><br/>"
104 "<li> - MS Live Communications Server 2003</li><br/>"
105 "<li> - Reuters Messaging</li><br/>"
106 "<br/>"
107 /* 2 */ "%s: <a href=\"" PACKAGE_URL "\">" PACKAGE_URL "</a><br/>"
108 /* 3,4 */ "%s: <a href=\"http://sourceforge.net/projects/sipe/forums/forum/688534\">%s</a><br/>"
109 /* 5,6 */ "%s: <a href=\"" PACKAGE_BUGREPORT "\">%s</a><br/>"
110 /* 7 */ "%s: <a href=\"https://transifex.net/projects/p/pidgin-sipe/c/mob-branch/\">Transifex.net</a><br/>"
111 /* 8 */ "%s: GPLv2+<br/>"
112 "<br/>"
113 /* 9 */ "%s:<br/>"
114 " - CERN<br/>"
115 " - Reuters Messaging network<br/>"
116 " - Deutsche Bank<br/>"
117 " - Merrill Lynch<br/>"
118 " - Wachovia<br/>"
119 " - Intel<br/>"
120 " - Nokia<br/>"
121 " - HP<br/>"
122 " - Symantec<br/>"
123 " - Accenture<br/>"
124 " - Capgemini<br/>"
125 " - Siemens<br/>"
126 " - Alcatel-Lucent<br/>"
127 " - BT<br/>"
128 "<br/>"
129 /* 10,11 */ "%s<a href=\"https://transifex.net/projects/p/pidgin-sipe/c/mob-branch/\">Transifex.net</a>%s.<br/>"
130 "<br/>"
131 /* 12 */ "<b>%s:</b><br/>"
132 " - Anibal Avelar<br/>"
133 " - Gabriel Burt<br/>"
134 " - Stefan Becker<br/>"
135 " - pier11<br/>"
136 " - Jakub Adam<br/>"
137 " - Tomáš Hrabčík<br/>"
138 "<br/>"
139 /* 13 */ "%s<br/>"
141 /* The next 13 texts make up the SIPE about note text */
142 /* About note, part 1/13: introduction */
143 _("A third-party plugin implementing extended version of SIP/SIMPLE used by various products"),
144 /* About note, part 2/13: home page URL (label) */
145 _("Home"),
146 /* About note, part 3/13: support forum URL (label) */
147 _("Support"),
148 /* About note, part 4/13: support forum name (hyperlink text) */
149 _("Help Forum"),
150 /* About note, part 5/13: bug tracker URL (label) */
151 _("Report Problems"),
152 /* About note, part 6/13: bug tracker URL (hyperlink text) */
153 _("Bug Tracker"),
154 /* About note, part 7/13: translation service URL (label) */
155 _("Translations"),
156 /* About note, part 8/13: license type (label) */
157 _("License"),
158 /* About note, part 9/13: known users */
159 _("We support users in such organizations as"),
160 /* About note, part 10/13: translation request, text before Transifex.net URL */
161 /* append a space if text is not empty */
162 _("Please help us to translate SIPE to your native language here at "),
163 /* About note, part 11/13: translation request, text after Transifex.net URL */
164 /* start with a space if text is not empty */
165 _(" using convenient web interface"),
166 /* About note, part 12/13: author list (header) */
167 _("Authors"),
168 /* About note, part 13/13: Localization credit */
169 /* PLEASE NOTE: do *NOT* simply translate the english original */
170 /* but write something similar to the following sentence: */
171 /* "Localization for <language name> (<language code>): <name>" */
172 _("Original texts in English (en): SIPE developers")
176 void sipe_core_deallocate(struct sipe_core_public *sipe_public)
178 struct sipe_core_private *sipe_private = SIPE_CORE_PRIVATE;
179 struct sipe_account_data *sip = SIPE_ACCOUNT_DATA_PRIVATE;
181 #ifdef HAVE_VV
182 if (sipe_private->media_call) {
183 sipe_media_handle_going_offline(sipe_private->media_call);
185 #endif
187 /* leave all conversations */
188 if (sipe_private->sessions) {
189 GSList *entry;
190 while ((entry = sipe_private->sessions) != NULL) {
191 sipe_session_close(sipe_private, entry->data);
195 if (sip->csta) {
196 sip_csta_close(sipe_private);
199 if (sipe_backend_connection_is_valid(SIPE_CORE_PUBLIC)) {
200 sipe_subscriptions_unsubscribe(sipe_private);
201 sip_transport_deregister(sipe_private);
204 sipe_connection_cleanup(sipe_private);
205 g_free(sipe_private->public.sip_name);
206 g_free(sipe_private->public.sip_domain);
207 g_free(sipe_private->username);
208 g_free(sip->email);
209 g_free(sip->password);
210 g_free(sip->authdomain);
211 g_free(sip->authuser);
212 g_free(sip->status);
213 g_free(sip->note);
214 g_free(sip->user_states);
216 sipe_buddy_free_all(sipe_private);
217 g_hash_table_destroy(sipe_private->buddies);
218 g_hash_table_destroy(sip->our_publications);
219 g_hash_table_destroy(sip->user_state_publications);
220 sipe_subscriptions_destroy(sipe_private);
222 if (sip->groups) {
223 GSList *entry = sip->groups;
224 while (entry) {
225 struct sipe_group *group = entry->data;
226 g_free(group->name);
227 g_free(group);
228 entry = entry->next;
231 g_slist_free(sip->groups);
233 if (sip->our_publication_keys) {
234 GSList *entry = sip->our_publication_keys;
235 while (entry) {
236 g_free(entry->data);
237 entry = entry->next;
240 g_slist_free(sip->our_publication_keys);
242 #ifdef HAVE_VV
243 g_free(sipe_private->mras_uri);
244 g_free(sipe_private->media_relay_username);
245 g_free(sipe_private->media_relay_password);
246 sipe_media_relay_list_free(sipe_private->media_relays);
247 #endif
249 g_free(sip);
250 g_free(sipe_private);
254 Local Variables:
255 mode: c
256 c-file-style: "bsd"
257 indent-tabs-mode: t
258 tab-width: 8
259 End: