Author: yamakenz
Date: Mon Feb 11 07:09:48 2008
New Revision: 5161

Modified:
  trunk/notify/uim-knotify3.cc
  trunk/notify/uim-libnotify.c
  trunk/po/POTFILES.in
  trunk/uim/canna.c
  trunk/uim/mana.c
  trunk/uim/plugin.c
  trunk/uim/skk.c
  trunk/uim/uim-error.c
  trunk/uim/uim-helper.c
  trunk/uim/uim-notify.h

Log:
* uim/uim-notify.h
 - Add a TODO comment
* uim/uim-error.c
 - (ERRMSG_UIM_HAS_BEEN_DISABLED): Enclose into N_()
 - (print_caught_error): Follow the message change
* uim/uim-helper.c
 - Fix uim-notify activation on compilation
* uim/plugin.c
* uim/canna.c
* uim/mana.c
* uim/skk.c
 - Include gettext.h
 - Add N_() to various messages for uim_notify_*()
* po/POTFILES.in
 - Add uim/{uim-error,plugin,canna,mana,skk}.c
* notify/uim-libnotify.c
 - (uim_libnotify_notify):
   * Fix return type int to uim_bool
   * Change error message header "uim: " to "libuim: "
   * Add a FIXME comment
* notify/uim-knotify3.cc
 - (send_knotify):
   * Change error message header "uim: " to "libuim: "
   * Add a FIXME comment


Modified: trunk/notify/uim-knotify3.cc
==============================================================================
--- trunk/notify/uim-knotify3.cc        (original)
+++ trunk/notify/uim-knotify3.cc        Mon Feb 11 07:09:48 2008
@@ -68,6 +68,7 @@
  return;
}

+/* FIXME: gettext msg */
static uim_bool
send_knotify(const char *eventstr, const char *msg, int level)
{
@@ -78,20 +79,20 @@
  QString event(eventstr), fromApp("uim"), text, sound(""), file("");
  int present = KNotifyClient::Messagebox | level;

-  snprintf(body, sizeof(body), "uim: %s", msg);
+  snprintf(body, sizeof(body), "libuim: %s", msg);
  fprintf(stderr, "%s\n", msg);

  strlcpy(body_short, body, sizeof(body_short));
  text = body_short;

  if (!kapp->dcopClient()->attach()) {
-    fprintf(stderr, "uim: cannot connect DCOP\n");
+    fprintf(stderr, "libuim: cannot connect DCOP\n");
    return UIM_FALSE;
  }
  arg << event << fromApp << text << sound << file << present << level;
  if (!kapp->dcopClient()->send("knotify", "Notify", 
"notify(QString,QString,QString,QString,QString,int,int)",
                                data)) {
-    fprintf(stderr, "uim: cannot send message via DCOP\n");
+    fprintf(stderr, "libuim: cannot send message via DCOP\n");
    return UIM_FALSE;
  }
  return UIM_TRUE;

Modified: trunk/notify/uim-libnotify.c
==============================================================================
--- trunk/notify/uim-libnotify.c        (original)
+++ trunk/notify/uim-libnotify.c        Mon Feb 11 07:09:48 2008
@@ -44,7 +44,8 @@

#define UIM_ICON UIM_PIXMAPSDIR "/uim-icon.png"

-static int
+/* FIXME: gettext body */
+static uim_bool
uim_libnotify_notify(int urgency, int timeout, const char *body)
{
  char body_short[256];
@@ -54,7 +55,7 @@

  strlcpy(body_short, body, sizeof(body_short));

-  fprintf(stderr, "uim: %s\n", body);
+  fprintf(stderr, "libuim: %s\n", body);

  if (!notify_is_initted()) {
    fprintf(stderr, "libnotify: libnotify is not initted\n");

Modified: trunk/po/POTFILES.in
==============================================================================
--- trunk/po/POTFILES.in        (original)
+++ trunk/po/POTFILES.in        Mon Feb 11 07:09:48 2008
@@ -57,4 +57,9 @@
scm/tutcode.scm
scm/viqr.scm
uim.desktop.in.in
+uim/uim-error.c
+uim/plugin.c
+uim/canna.c
+uim/mana.c
+uim/skk.c
uim/m17nlib.c

Modified: trunk/uim/canna.c
==============================================================================
--- trunk/uim/canna.c   (original)
+++ trunk/uim/canna.c   Mon Feb 11 07:09:48 2008
@@ -47,6 +47,7 @@
#include "uim-scm.h"
#include "uim-scm-abbrev.h"
#include "uim-notify.h"
+#include "gettext.h"
#include "plugin.h"

#if 0
@@ -166,7 +167,10 @@
  buf = diclist;
  for (i = 0; i < dic_num; i++) {
    if (RkMountDic(cc->rk_context_id, buf, 0) == ERR) {
-      uim_notify_fatal("uim-canna: Failed to mount dictionary %s", buf);
+      /* FIXME: gettext here to expand %s in accordance with the
+       * locale for the selected notification agent. See also the TODO
+       * comment of uim-notify.h  -- YamaKen 2008-02-11 */
+ uim_notify_fatal(N_("uim-canna: Failed to mount dictionary %s."), buf);
    }
    buflen = strlen(buf) + sizeof((char)'\0');
    buf += buflen;

Modified: trunk/uim/mana.c
==============================================================================
--- trunk/uim/mana.c    (original)
+++ trunk/uim/mana.c    Mon Feb 11 07:09:48 2008
@@ -52,6 +52,7 @@
#include "uim-util.h"
#include "plugin.h"
#include "uim-notify.h"
+#include "gettext.h"

#define MANA_COMMAND "mana"

@@ -99,7 +100,7 @@
        fgets(buf, sizeof(buf), *read_fp);
        if (buf != NULL) {
          if (strcmp(buf, "err") == 0)
-            uim_notify_fatal("uim-mana: mana not found");
+            uim_notify_fatal(N_("uim-mana: Command 'mana' not found."));
          else
            uim_notify_fatal("uim-mana: %s", buf);
        }
@@ -172,7 +173,7 @@
    fclose(mana_r);
    fclose(mana_w);
    mana_r = mana_w = NULL;
-    uim_notify_fatal("uim-mana: mana not found");
+    uim_notify_fatal(N_("uim-mana: Command 'mana' not found."));
    return uim_scm_f();
  }


Modified: trunk/uim/plugin.c
==============================================================================
--- trunk/uim/plugin.c  (original)
+++ trunk/uim/plugin.c  Mon Feb 11 07:09:48 2008
@@ -52,7 +52,10 @@
#include "uim-scm-abbrev.h"
#include "plugin.h"
#include "uim-internal.h"
+#if UIM_USE_NOTIFY
#include "uim-notify.h"
+#endif
+#include "gettext.h"

#ifndef HAVE_DLFUNC
#define dlfunc(handle, symbol) \
@@ -164,7 +167,7 @@
  free(plugin_lib_filename);

  if (library == NULL) {
-    uim_notify_fatal("load failed %s", dlerror());
+    uim_notify_fatal(N_("%s plugin: Load failed."), dlerror());
    free(plugin_scm_filename);
    return uim_scm_f();
  }
@@ -174,7 +177,7 @@
  plugin_instance_quit
    = (void (*)(void))dlfunc(library, "uim_plugin_instance_quit");
  if (!plugin_instance_init) {
-    uim_notify_fatal("%s plugin init failed", plugin_name);
+    uim_notify_fatal(N_("%s plugin: Init failed."), plugin_name);
    free(plugin_scm_filename);
    return uim_scm_f();
  }
@@ -186,8 +189,11 @@

    succeeded = uim_scm_require_file(plugin_scm_filename);
    if (!succeeded) {
-      uim_notify_fatal("%s plugin subsequent %s loading failed",
-             plugin_name, plugin_scm_filename);
+      /* FIXME: gettext here to expand %s in accordance with the
+       * locale for the selected notification agent. See also the TODO
+       * comment of uim-notify.h  -- YamaKen 2008-02-11 */
+      uim_notify_fatal(N_("%s plugin: Subsequent %s load failed."),
+                      plugin_name, plugin_scm_filename);
      free(plugin_scm_filename);
      return uim_scm_f();
    }

Modified: trunk/uim/skk.c
==============================================================================
--- trunk/uim/skk.c     (original)
+++ trunk/uim/skk.c     Mon Feb 11 07:09:48 2008
@@ -63,6 +63,7 @@
#include "uim-helper.h"
#include "plugin.h"
#include "uim-notify.h"
+#include "gettext.h"

#include "bsdlook.h"

@@ -983,7 +984,7 @@
          p++;
          c = *p;
          if (*p == '\0') {
-           uim_notify_fatal("uim-skk: error in expand_str");
+           uim_notify_fatal(N_("uim-skk: error in expand_str"));
            return NULL;
          }
          if (c >= '0' && c <= '7') {
@@ -998,7 +999,7 @@
      }
    }
    if ((i + 1) >= BUFSIZ) {
-      uim_notify_fatal("uim-skk: too long word");
+      uim_notify_fatal(N_("uim-skk: too long word"));
      return NULL;
    }
    buf[i] = c;
@@ -3596,7 +3597,10 @@
    if (connect(sock, ai->ai_addr, ai->ai_addrlen) == 0)
      break;
    else
- uim_notify_fatal("uim-skk: connect to %s port %s failed", hostname, port);
+      /* FIXME: gettext here to expand %s in accordance with the
+       * locale for the selected notification agent. See also the TODO
+       * comment of uim-notify.h  -- YamaKen 2008-02-11 */
+ uim_notify_fatal(N_("uim-skk: connect to %s port %s failed"), hostname, port);
    close(sock);
    sock = -1;
  }

Modified: trunk/uim/uim-error.c
==============================================================================
--- trunk/uim/uim-error.c       (original)
+++ trunk/uim/uim-error.c       Mon Feb 11 07:09:48 2008
@@ -46,6 +46,7 @@
#if UIM_USE_NOTIFY && !UIM_NON_LIBUIM_PROG
#include "uim-notify.h"
#endif
+#include "gettext.h"


#ifndef EX_SOFTWARE
@@ -53,7 +54,7 @@
#endif

#define ERRMSG_UIM_HAS_BEEN_DISABLED                                    \
-  "All functionality has been disabled to save user application data."
+  N_("All functionality has been disabled to save user application data.")

static void print_caught_error(void);

@@ -87,7 +88,8 @@
    fputs(err_msg, stderr);
    fputs("\n", stderr);
    if (fatal_errored) {
-      fputs("libuim: " ERRMSG_UIM_HAS_BEEN_DISABLED, stderr);
+      fputs("libuim: ", stderr);
+      fputs(ERRMSG_UIM_HAS_BEEN_DISABLED, stderr);
      fputs("\n", stderr);
    }


Modified: trunk/uim/uim-helper.c
==============================================================================
--- trunk/uim/uim-helper.c      (original)
+++ trunk/uim/uim-helper.c      Mon Feb 11 07:09:48 2008
@@ -58,9 +58,10 @@
 *   2. whether these errors should be notified to endusers
 * -- 2008-01-15 YamaKen
 */
+#undef USE_UIM_NOTIFY
#define USE_UIM_NOTIFY 0

-#if USE_UIM_NOTIFY
+#if USE_UIM_NOTIFY && !UIM_NON_LIBUIM_PROG
#include "uim-notify.h"
#endif

@@ -214,7 +215,7 @@
  uid_t euid;
  gid_t egid;
  if (getpeereid(fd, &euid, &egid) < 0) {
-#if USE_UIM_NOTIFY
+#if USE_UIM_NOTIFY && !UIM_NON_LIBUIM_PROG
    uim_notify_fatal("uim_helper: %s", strerror(errno));
#else
    perror("getpeereid failed");
@@ -222,7 +223,7 @@
    return -1;
  }
  if ((euid != 0) && (euid != getuid())) {
-#if USE_UIM_NOTIFY
+#if USE_UIM_NOTIFY && !UIM_NON_LIBUIM_PROG
    uim_notify_fatal("uim_helper: uid mismatch");
#else
    fprintf(stderr, "uid mismatch\n");

Modified: trunk/uim/uim-notify.h
==============================================================================
--- trunk/uim/uim-notify.h      (original)
+++ trunk/uim/uim-notify.h      Mon Feb 11 07:09:48 2008
@@ -32,9 +32,16 @@

/*                         !WARNING!

-   This API is experimental.
+   This API is experimental and unstable.

*/
+
+/* TODO: Add a new API to get the locale for the currently activated
+ * notification agent to gettext message strings contain format string
+ * such as "uim-canna: Failed to mount dictionary %s." in client
+ * side. The locale of the process is not appropriate since it may be
+ * ja_JP.eucJP and so on and ordinary notification agents expect
+ * UTF-8.  -- YamaKen 2008-02-11 */

#ifndef _uim_notify_h_included_
#define _uim_notify_h_included_

Reply via email to