Back to index

im-sdk  12.3.91
Defines | Functions | Variables
main.cpp File Reference
#include <strings.h>
#include <locale.h>
#include <stdlib.h>
#include <unistd.h>
#include <X11/Intrinsic.h>
#include <X11/Shell.h>
#include "XIMProtocol.hh"
#include "IMArg.h"
#include "IMProtocol.hh"
#include "IMTriggerKeyList.hh"
#include "ResourceDB.hh"

Go to the source code of this file.

Defines

#define SetArg(arg, n, d)   ((void)( (arg).id = (n), (arg).value = (char*)(d) ))

Functions

static char * check_locale (int argc, char *argv[])
void initialize (int argc, char *argv[])
void run ()
int main (int argc, char *argv[])

Variables

static IMProtocolximp = 0
static XrmOptionDescRec rdb_options []

Define Documentation

#define SetArg (   arg,
  n,
  d 
)    ((void)( (arg).id = (n), (arg).value = (char*)(d) ))

Definition at line 67 of file main.cpp.


Function Documentation

static char* check_locale ( int  argc,
char *  argv[] 
) [static]

Definition at line 88 of file main.cpp.

                                     {
  int i;

  for (i = 1; i < argc; i++) {
    if(!strcmp(argv[i], "-lc_basiclocale"))
      return (argv[i+1]);
  }
  return (char *)"";
}

Here is the caller graph for this function:

void initialize ( int  argc,
char *  argv[] 
)

Definition at line 112 of file main.cpp.

                                   { 
  XtAppContext app = (XtAppContext)0;
  const char *class_name = "Iiimx";
  const char *app_name = "iiimx";

#ifdef USE_IMP_MANAGER
  ximp = IMProtocolManager::getInstance(IMProtocolManager::XIMP40);
#else
  ximp = new XIMProtocol(0, 0);
#endif
  if (!ximp) exit(1);

#ifdef SUPPORT_R6IM
#ifdef USE_IMP_MANAGER
  r6im = IMProtocolManager::getInstance(IMProtocolManager::R6IMP);
#else
  r6im = new R6IMProtocol(0, 0);
#endif
#endif

  // just workaround
#ifndef linux
  XInitThreads();
#endif

  setlocale(LC_ALL, check_locale(argc, argv));
  char *primary_locale = strdup(setlocale(LC_CTYPE, (char*)0));
  // strip modifier
  char *p = strchr(primary_locale, '@');
  if (p) *p = '\0';
  // strip encoding
  p = strchr(primary_locale, '.');
  if (p) *p = '\0';
  // strip territory. can we ?
  // p = strchr(primary_locale, '_');
  // if (p) *p = '\0';

  XSetLocaleModifiers("");

  Widget toplevel = XtOpenApplication(&app, class_name,
                                  rdb_options,
                                  XtNumber(rdb_options),
                                  &argc, argv,
                                  0, // fallback resources
                                  applicationShellWidgetClass,
                                  0, 0); // args and num_args
  int n;

  ResourceDB *resource = new ResourceDB(toplevel);

  char *trigger_keys = 0;
  IMTriggerKeyList key_list;
  Bool disable_status_area;
  Bool static_event_flow;

  char *if_name = 0;

  char *font_name = 0;
  n = 0;
  IMArg res[5];
  SetArg(res[n], ResourceDB::RDB_CONV_ON_KEY, &trigger_keys); n++;
  SetArg(res[n], ResourceDB::RDB_IF_NAME, &if_name); n++;
  SetArg(res[n], ResourceDB::RDB_FS_NAME, &font_name); n++;
  SetArg(res[n], ResourceDB::RDB_DISABLE_STATUS_AREA, &disable_status_area); n++;
  SetArg(res[n], ResourceDB::RDB_STATIC_EVENT_FLOW, &static_event_flow); n++;
  resource->getValues(res, n);

  if (trigger_keys) {
    if (!static_event_flow) {
      key_list.add(trigger_keys);
    }
    XtFree(trigger_keys);
  }

  // for XIMP initialization
  n = 0;
  IMArg args[15];
  SetArg(args[n], IMProtocol::ServerName, app_name); n++;
  SetArg(args[n], IMProtocol::VendorName, "Sun"); n++;
  SetArg(args[n], IMProtocol::PrimaryInputLocale, primary_locale); n++;
  SetArg(args[n], IMProtocol::ConversionOnKeys, &key_list); n++;
  SetArg(args[n], IMProtocol::DisplayConnection, XtDisplay(toplevel)); n++;
  if (if_name && if_name[0]) {
    SetArg(args[n], IMProtocol::IFName, if_name); n++;
  }
  if (font_name && font_name[0]) {
    SetArg(args[n], IMProtocol::DefaultFontName, font_name); n++;
  }
  SetArg(args[n], IMProtocol::AppName, "IIIMX XIM Server"); n++;
  SetArg(args[n], IMProtocol::DisableStatusArea, disable_status_area); n++;

  ximp->set_values(args, n);

#ifdef SUPPORT_R6IM
  // for X11R6 IMP initialization
  n = 0;
  Display *display2 = XOpenDisplay("");   // must be different from XIMP
  SetArg(args[n], IMProtocol::ServerName, app_name); n++;
  SetArg(args[n], IMProtocol::VendorName, "Sun"); n++;
  SetArg(args[n], IMProtocol::PrimaryInputLocale, primary_locale); n++;
  SetArg(args[n], IMProtocol::ConversionOnKeys, &key_list); n++;
  SetArg(args[n], IMProtocol::DisplayConnection, display2); n++;
  if (if_name && if_name[0]) {
    SetArg(args[n], IMProtocol::IFName, if_name); n++;
  }
  if (font_name && font_name[0]) {
    SetArg(args[n], IMProtocol::DefaultFontName, font_name); n++;
  }
  SetArg(args[n], IMProtocol::AppName, "IIIMX XIM Server"); n++;
  SetArg(args[n], IMProtocol::DisableStatusArea, disable_status_area); n++;

  const char *transport = "X/"; // use X
  SetArg(args[n], IMProtocol::TransportAddress, transport); n++;
  r6im->set_values(args, n);
#endif

  return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( int  argc,
char *  argv[] 
)

Definition at line 242 of file main.cpp.

                             {
  initialize(argc, argv);
  run();
  while(1) {
    sleep(10000000);
  }
  return 0;
}

Here is the call graph for this function:

void run ( )

Definition at line 232 of file main.cpp.

      {
#ifndef linux
  ximp->run();
#endif
#ifdef SUPPORT_R6IM
  r6im->run();
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

XrmOptionDescRec rdb_options[] [static]
Initial value:
 {
   {(char*)"-if",    (char*)"*engineModule",     XrmoptionSepArg, 0},
   {(char*)"-port",  (char*)"*portNumber",              XrmoptionSepArg, 0},
   {(char*)"-ximp40",       (char*)"*ximp40",           XrmoptionNoArg, (XPointer)"true"},
   {(char*)"-iiimp", (char*)"*iiimp",            XrmoptionNoArg, (XPointer)"true"},
   {(char*)"-fs",    (char*)"*fontSet",          XrmoptionSepArg, NULL},
   {(char*)"-lucbg", (char*)"*lookupBackground", XrmoptionSepArg, NULL},
   {(char*)"-staticEventFlow",     (char*)"*staticEventFlow", XrmoptionNoArg, (XPointer)"true"},
   {(char*)"-noProps", (char*)"*HttProps",              XrmoptionNoArg, (XPointer)"false"}
   
}

Definition at line 74 of file main.cpp.

IMProtocol* ximp = 0 [static]

Definition at line 69 of file main.cpp.