Porting Toolkit to Symbian. It should work while some sporadic
[silc.git] / lib / silcutil / symbian / silcsymbianutil.cpp
1 /*
2
3   silcsymbianutil.cpp
4
5   Author: Pekka Riikonen <priikone@silcnet.org>
6
7   Copyright (C) 2006 - 2007 Pekka Riikonen
8
9   This program is free software; you can redistribute it and/or modify
10   it under the terms of the GNU General Public License as published by
11   the Free Software Foundation; version 2 of the License.
12
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.
17
18 */
19
20 #include "silc.h"
21 #include <e32std.h>
22 #include <e32svr.h>
23
24 extern "C" {
25
26 /* Returns the username of the user. */
27
28 char *silc_get_username()
29 {
30 #if 0
31   char *logname = NULL;
32
33   logname = getlogin();
34   if (!logname) {
35     struct passwd *pw;
36
37     pw = getpwuid(getuid());
38     if (!pw)
39       return strdup("User");
40
41     logname = pw->pw_name;
42   }
43
44   return strdup(logname);
45 #else
46   return strdup("Symbian");
47 #endif /* 0 */
48 }
49
50 /* Returns the real name of ther user. */
51
52 char *silc_get_real_name()
53 {
54 #if 0
55   char *realname = NULL;
56   struct passwd *pw;
57
58   pw = getpwuid(getuid());
59   if (!pw)
60     return strdup("No Name");
61
62   if (strchr(pw->pw_gecos, ','))
63     *strchr(pw->pw_gecos, ',') = 0;
64
65   if (!strlen(pw->pw_gecos))
66     return strdup("No Name");
67
68   realname = strdup(pw->pw_gecos);
69
70   return realname;
71 #else
72   return strdup("Lastname");
73 #endif /* 0 */
74 }
75
76 /* Return current time to struct timeval. */
77
78 int silc_gettimeofday(struct timeval *p)
79 {
80   return gettimeofday(p, NULL);
81 }
82
83 int silc_file_set_nonblock(int fd)
84 {
85   return 0;
86 }
87
88 void silc_symbian_usleep(long microseconds)
89 {
90   User::After(microseconds / 1000);
91 }
92
93 void silc_symbian_debug(const char *function, int line, char *string)
94 {
95   fprintf(stderr, "%s:%d: %s\n", function, line, string);
96   // RDebug::Print(_L("%s:%d: %s"), function, line, string);
97 }
98
99 } /* extern "C" */