1 /*
2 
3   silcsymbianutil.cpp
4 
5   Author: Pekka Riikonen <priikone@silcnet.org>
6 
7   Copyright (C) 2006 - 2007 Pekka Riikonen
8 
9   The contents of this file are subject to one of the Licenses specified
10   in the COPYING file;  You may not use this file except in compliance
11   with the License.
12 
13   The software distributed under the License is distributed on an "AS IS"
14   basis, in the hope that it will be useful, but WITHOUT WARRANTY OF ANY
15   KIND, either expressed or implied.  See the COPYING file for more
16   information.
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 
silc_get_username()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 
silc_get_real_name()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 
silc_gettimeofday(struct timeval * p)78 int silc_gettimeofday(struct timeval *p)
79 {
80   return gettimeofday(p, NULL);
81 }
82 
silc_file_set_nonblock(int fd)83 int silc_file_set_nonblock(int fd)
84 {
85   return 0;
86 }
87 
silc_symbian_usleep(long microseconds)88 void silc_symbian_usleep(long microseconds)
89 {
90   User::After(microseconds / 1000);
91 }
92 
silc_symbian_debug(const char * function,int line,char * string)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" */
100