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