1 /* |
|
2 * Copyright (C) 2003-2007 Imendio AB |
|
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary/subsidiaries. |
|
4 * Copyright (C) 2007 Collabora Ltd. |
|
5 * |
|
6 * This program is free software; you can redistribute it and/or |
|
7 * modify it under the terms of the GNU Lesser General Public License as |
|
8 * published by the Free Software Foundation; either version 2 of the |
|
9 * License, or (at your option) any later version. |
|
10 * |
|
11 * This program is distributed in the hope that it will be useful, |
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 * Lesser General Public License for more details. |
|
15 * |
|
16 * You should have received a copy of the GNU Lesser General Public |
|
17 * License along with this program; if not, write to the |
|
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|
19 * Boston, MA 02111-1307, USA. |
|
20 */ |
|
21 |
|
22 #include <e32std.h> |
|
23 #include "libloudmouth_wsd_solution.h" |
|
24 #include <string.h> |
|
25 |
|
26 |
|
27 #include <pls.h> // For emulator WSD API |
|
28 |
|
29 const TUid KLibLoudmouthUid3 = {0x10281F99}; // This is the UID of the library |
|
30 struct libloudmouth_global_struct *libloudmouth_ImpurePtr() |
|
31 { |
|
32 #if defined(__WINSCW__) || defined(__WINS__) |
|
33 |
|
34 // Access the PLS of this process |
|
35 struct libloudmouth_global_struct *g = Pls<struct libloudmouth_global_struct>(KLibLoudmouthUid3, &libloudmouth_Init); |
|
36 return g; |
|
37 |
|
38 #else |
|
39 |
|
40 return NULL; |
|
41 |
|
42 #endif |
|
43 }; |
|
44 |
|
45 int libloudmouth_Init(libloudmouth_global_struct *g) |
|
46 { |
|
47 |
|
48 TypeNames type_names[14] = { |
|
49 { LM_MESSAGE_TYPE_MESSAGE, "message" }, |
|
50 { LM_MESSAGE_TYPE_PRESENCE, "presence" }, |
|
51 { LM_MESSAGE_TYPE_IQ, "iq" }, |
|
52 { LM_MESSAGE_TYPE_STREAM, "stream:stream" }, |
|
53 { LM_MESSAGE_TYPE_STREAM_FEATURES, "stream:features" }, |
|
54 { LM_MESSAGE_TYPE_STREAM_ERROR, "stream:error" }, |
|
55 { LM_MESSAGE_TYPE_AUTH, "auth" }, |
|
56 { LM_MESSAGE_TYPE_CHALLENGE, "challenge" }, |
|
57 { LM_MESSAGE_TYPE_RESPONSE, "response" }, |
|
58 { LM_MESSAGE_TYPE_SUCCESS, "success" }, |
|
59 { LM_MESSAGE_TYPE_FAILURE, "failure" }, |
|
60 { LM_MESSAGE_TYPE_PROCEED, "proceed" }, |
|
61 { LM_MESSAGE_TYPE_STARTTLS, "starttls" }, |
|
62 { LM_MESSAGE_TYPE_UNKNOWN, NULL } |
|
63 |
|
64 }; |
|
65 |
|
66 SubTypeNames sub_type_names[14] = { |
|
67 { LM_MESSAGE_SUB_TYPE_NORMAL, "normal" }, |
|
68 { LM_MESSAGE_SUB_TYPE_CHAT, "chat" }, |
|
69 { LM_MESSAGE_SUB_TYPE_GROUPCHAT, "groupchat" }, |
|
70 { LM_MESSAGE_SUB_TYPE_HEADLINE, "headline" }, |
|
71 { LM_MESSAGE_SUB_TYPE_UNAVAILABLE, "unavailable" }, |
|
72 { LM_MESSAGE_SUB_TYPE_PROBE, "probe" }, |
|
73 { LM_MESSAGE_SUB_TYPE_SUBSCRIBE, "subscribe" }, |
|
74 { LM_MESSAGE_SUB_TYPE_UNSUBSCRIBE, "unsubscribe" }, |
|
75 { LM_MESSAGE_SUB_TYPE_SUBSCRIBED, "subscribed" }, |
|
76 { LM_MESSAGE_SUB_TYPE_UNSUBSCRIBED, "unsubscribed" }, |
|
77 { LM_MESSAGE_SUB_TYPE_GET, "get" }, |
|
78 { LM_MESSAGE_SUB_TYPE_SET, "set" }, |
|
79 { LM_MESSAGE_SUB_TYPE_RESULT, "result" }, |
|
80 { LM_MESSAGE_SUB_TYPE_ERROR, "error" } |
|
81 }; |
|
82 gchar base_64_chars[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; |
|
83 |
|
84 gchar encoding1[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; |
|
85 |
|
86 gchar retval[41] = ""; |
|
87 |
|
88 char buffer[256] = ""; |
|
89 |
|
90 if(g) |
|
91 { |
|
92 //g->GET_WSD_VAR_NAME(debug_flags,lm_debug,g) = Flags; |
|
93 |
|
94 g->GET_WSD_VAR_NAME(initialized,lm_debug,g) = EFalse; |
|
95 g->GET_WSD_VAR_NAME(log_handler_id,lm_debug,g) = 0; |
|
96 memcpy (&(g->GET_WSD_VAR_NAME(type_names,lm_message,s)), type_names, 13*sizeof(TypeNames)); |
|
97 memcpy (&(g->GET_WSD_VAR_NAME(sub_type_names,lm_message,s)), sub_type_names, 14*sizeof(SubTypeNames)); |
|
98 g->GET_WSD_VAR_NAME(initialized,lm_ssl_openssl,s) = EFalse; |
|
99 g->GET_WSD_VAR_NAME(last_id,lm_utils, s) = 0; |
|
100 |
|
101 strcpy((g->GET_WSD_VAR_NAME(base64chars,lm_utils,s)), base_64_chars); |
|
102 |
|
103 strcpy((g->GET_WSD_VAR_NAME(ret_val,lm_sha,s)), retval); |
|
104 |
|
105 strcpy((g->GET_WSD_VAR_NAME(encoding,lm_base64,s)), encoding1); |
|
106 |
|
107 strcpy((g->GET_WSD_VAR_NAME(buf,lm_misc,s)), buffer); |
|
108 |
|
109 g->GET_WSD_VAR_NAME(initialised,lm_sock,g) = EFalse; |
|
110 return 0; |
|
111 } |
|
112 return 1; |
|
113 } |
|
114 |
|