Porting Toolkit to Symbian. It should work while some sporadic
[silc.git] / lib / silcutil / symbian / silcsymbianutil.cpp
index 93ae79ab41b05c6334ed1bcbf62730593bc56a54..691ec677d4f4b386bd9a01ea625c3fc5dbbc1c08 100644 (file)
@@ -1,74 +1,99 @@
-/*\r
-\r
-  silcsymbianutil.cpp\r
-\r
-  Author: Pekka Riikonen <priikone@silcnet.org>\r
-\r
-  Copyright (C) 2006 Pekka Riikonen\r
-\r
-  This program is free software; you can redistribute it and/or modify\r
-  it under the terms of the GNU General Public License as published by\r
-  the Free Software Foundation; version 2 of the License.\r
-\r
-  This program is distributed in the hope that it will be useful,\r
-  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-  GNU General Public License for more details.\r
-\r
-*/\r
-\r
-#include "silc.h"\r
-\r
-/* Returns the username of the user. */\r
-\r
-char *silc_get_username()\r
-{\r
-  char *logname = NULL;\r
-\r
-  logname = getlogin();\r
-  if (!logname) {\r
-    struct passwd *pw;\r
-\r
-    pw = getpwuid(getuid());\r
-    if (!pw)\r
-      return strdup("User");\r
-\r
-    logname = pw->pw_name;\r
-  }\r
-\r
-  return strdup(logname);\r
-}\r
-\r
-/* Returns the real name of ther user. */\r
-\r
-char *silc_get_real_name()\r
-{\r
-  char *realname = NULL;\r
-  struct passwd *pw;\r
-\r
-  pw = getpwuid(getuid());\r
-  if (!pw)\r
-    return strdup("No Name");\r
-\r
-  if (strchr(pw->pw_gecos, ','))\r
-    *strchr(pw->pw_gecos, ',') = 0;\r
-\r
-  if (!strlen(pw->pw_gecos))\r
-    return strdup("No Name");\r
-\r
-  realname = strdup(pw->pw_gecos);\r
-\r
-  return realname;\r
-}\r
-\r
-/* Return current time to struct timeval. */\r
-\r
-int silc_gettimeofday(struct timeval *p)\r
-{\r
-  return gettimeofday(p, NULL);\r
-}\r
-\r
-int silc_file_set_nonblock(int fd)\r
-{\r
-  return 0;\r
-}\r
+/*
+
+  silcsymbianutil.cpp
+
+  Author: Pekka Riikonen <priikone@silcnet.org>
+
+  Copyright (C) 2006 - 2007 Pekka Riikonen
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; version 2 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+*/
+
+#include "silc.h"
+#include <e32std.h>
+#include <e32svr.h>
+
+extern "C" {
+
+/* Returns the username of the user. */
+
+char *silc_get_username()
+{
+#if 0
+  char *logname = NULL;
+
+  logname = getlogin();
+  if (!logname) {
+    struct passwd *pw;
+
+    pw = getpwuid(getuid());
+    if (!pw)
+      return strdup("User");
+
+    logname = pw->pw_name;
+  }
+
+  return strdup(logname);
+#else
+  return strdup("Symbian");
+#endif /* 0 */
+}
+
+/* Returns the real name of ther user. */
+
+char *silc_get_real_name()
+{
+#if 0
+  char *realname = NULL;
+  struct passwd *pw;
+
+  pw = getpwuid(getuid());
+  if (!pw)
+    return strdup("No Name");
+
+  if (strchr(pw->pw_gecos, ','))
+    *strchr(pw->pw_gecos, ',') = 0;
+
+  if (!strlen(pw->pw_gecos))
+    return strdup("No Name");
+
+  realname = strdup(pw->pw_gecos);
+
+  return realname;
+#else
+  return strdup("Lastname");
+#endif /* 0 */
+}
+
+/* Return current time to struct timeval. */
+
+int silc_gettimeofday(struct timeval *p)
+{
+  return gettimeofday(p, NULL);
+}
+
+int silc_file_set_nonblock(int fd)
+{
+  return 0;
+}
+
+void silc_symbian_usleep(long microseconds)
+{
+  User::After(microseconds / 1000);
+}
+
+void silc_symbian_debug(const char *function, int line, char *string)
+{
+  fprintf(stderr, "%s:%d: %s\n", function, line, string);
+  // RDebug::Print(_L("%s:%d: %s"), function, line, string);
+}
+
+} /* extern "C" */