Back to index

im-sdk  12.3.91
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes
IMDesktop Class Reference

#include <IMDesktop.hh>

Collaboration diagram for IMDesktop:
Collaboration graph
[legend]

List of all members.

Public Types

enum  IMDESKTOP_ATTRS {
  CLIENT_HOST, CLIENT_NAME, OS_NAME, OS_ARCH,
  OS_VERSION, X_DISPLAY_NAME, X_SERVER_VENDOR
}
enum  CLIENT_TYPE {
  IIIMXCF, IIIMJCF, IIIMECF, IIIMGCF,
  UNKNOWN_CLIENT
}
typedef map< int, u16stringIMDesktopAttr

Public Member Functions

iml_desktop_trequest_iml_desktop (LEContext &lec)
void release_iml_desktop (LEContext &lec, iml_desktop_t *iml_desktop)
bool match (IMDesktopAttr &attrs)
const u16stringget_attr (enum IMDESKTOP_ATTRS attr)
const string & get_desktop_display_name () const
enum CLIENT_TYPE get_client_type () const
bool iiim_xbe_p () const
void get_iml_desktop_args (vector< IMArg > &args)
void get_lecontext_args (vector< IMArg > &args)
 IMDesktop (IMUser *pu)
 IMDesktop (IMUser *pu, IMDesktopAttr &attrs)
virtual ~IMDesktop ()

Private Types

typedef map< LEBase
*, iml_desktop_t * > 
IMLDesktopMap

Private Member Functions

enum CLIENT_TYPE void initialize ()
iml_desktop_tcreate_iml_desktop (LEContext &lec)

Private Attributes

IMUserpuser
IMDesktopAttr attrs
bool iiim_xbe
string desktop_display_name
IMLDesktopMap iml_desktop_map

Detailed Description

Definition at line 12 of file IMDesktop.hh.


Member Typedef Documentation

Definition at line 24 of file IMDesktop.hh.

typedef map<LEBase*, iml_desktop_t*> IMDesktop::IMLDesktopMap [private]

Definition at line 44 of file IMDesktop.hh.


Member Enumeration Documentation

Enumerator:
IIIMXCF 
IIIMJCF 
IIIMECF 
IIIMGCF 
UNKNOWN_CLIENT 

Definition at line 26 of file IMDesktop.hh.

Enumerator:
CLIENT_HOST 
CLIENT_NAME 
OS_NAME 
OS_ARCH 
OS_VERSION 
X_DISPLAY_NAME 
X_SERVER_VENDOR 

Definition at line 15 of file IMDesktop.hh.


Constructor & Destructor Documentation

Definition at line 293 of file IMDesktop.cpp.

{
    puser = pu;
    initialize();
}

Here is the call graph for this function:

IMDesktop::IMDesktop ( IMUser pu,
IMDesktopAttr attrs 
)

Definition at line 301 of file IMDesktop.cpp.

{
    puser = pu;
    attrs = x_attrs;
    initialize();
}

Here is the call graph for this function:

IMDesktop::~IMDesktop ( ) [virtual]

Definition at line 311 of file IMDesktop.cpp.

{
    LEBase *plebase;
    iml_desktop_t *pidt;
    IMLDesktopMap::iterator it;
    for (it = iml_desktop_map.begin(); it != iml_desktop_map.end(); it++) {
       plebase = it->first;
       pidt = it->second;
       plebase->close_iml_desktop(pidt);
       del_user(pidt);
    }
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 62 of file IMDesktop.cpp.

{
    iml_desktop_t *pidt;
    const char *username, *hostname, *displayname;
    IMDesktopAttr::iterator it;
    IMConnection *pimc = lec.get_inputcontext()->get_imconnection();

    username = puser->get_username().get_charstr();
    if (!username) username = "";
    hostname = pimc->get_hostname().c_str();

    it = attrs.find(X_DISPLAY_NAME);
    if (it != attrs.end()) {
       displayname = it->second.get_charstr();
       if (!displayname)
           displayname = unknown_display_name;
    } else {
       displayname = unknown_display_name;
    }
    pidt = new_user(lec.get_lebase()->get_iml_if(),
                  username, hostname, displayname);

    return pidt;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 167 of file IMDesktop.cpp.

{
    IMDesktopAttr::iterator it = attrs.find(attr);
    if (it == attrs.end()) return NULL;
    return &it->second;
}

Here is the caller graph for this function:

enum CLIENT_TYPE IMDesktop::get_client_type ( ) const [inline]

Definition at line 67 of file IMDesktop.hh.

    { return client_type; }

Here is the caller graph for this function:

const string& IMDesktop::get_desktop_display_name ( ) const [inline]

Definition at line 65 of file IMDesktop.hh.

    { return desktop_display_name; }

Here is the caller graph for this function:

void IMDesktop::get_iml_desktop_args ( vector< IMArg > &  args)

Definition at line 177 of file IMDesktop.cpp.

{
    IMArg a;

    args.reserve(MAX_UI_ATTRIBUTE);

    const u16string *pstr;

    a.id = UI_USER_NAME;
    a.value = (char*) puser->get_username().get_charstr();
    if (!a.value) a.value = "Nobody";
    args.push_back(a);

    a.id = UI_HOST_NAME;
    pstr = get_attr(IMDesktop::CLIENT_HOST);
    if (pstr && pstr->get_charstr()) {
       a.value = (char*) pstr->get_charstr();
    } else {
       LOG_DEBUG("client host name is unknown.  It must be a problem.");
       a.value = "unknown";
    }
    args.push_back(a);

    a.id = UI_DISPLAY_ID;
    a.value = (char*) get_desktop_display_name().c_str();
    args.push_back(a);

    a.id = UI_PROTOCOL_TYPE;
    if (iiim_xbe_p())
       a.value = UI_PROTOCOL_TYPE_XIMP;
    else
       a.value = UI_PROTOCOL_TYPE_IIIMP;
    args.push_back(a);

    a.id = UI_CLIENT_TYPE;
    switch (get_client_type()) {
      case IMDesktop::IIIMXCF:
      case IMDesktop::IIIMGCF:
       a.value = UI_CLIENT_TYPE_X;
       break;
      case IMDesktop::IIIMJCF:
       a.value = UI_CLIENT_TYPE_JAVA;
       break;
      case IMDesktop::IIIMECF:
      case IMDesktop::UNKNOWN_CLIENT:
      default:
       a.value = UI_CLIENT_TYPE_UNKNOWN;
       break;
    }
    args.push_back(a);

    a.id = UI_XSERVER_VENDOR;
    pstr = get_attr(IMDesktop::X_SERVER_VENDOR);
    if (pstr && pstr->get_charstr()) {
       a.value = (char*) pstr->get_charstr();
    } else {
       a.value = "unknown";
    }
    args.push_back(a);

    a.id = UI_OS_NAME;
    pstr = get_attr(IMDesktop::OS_NAME);
    if (pstr && pstr->get_charstr()) {
       a.value = (char*) pstr->get_charstr();
    } else {
       a.value = "unknown";
    }
    args.push_back(a);

    a.id = UI_OS_ARCH;
    pstr = get_attr(IMDesktop::OS_ARCH);
    if (pstr && pstr->get_charstr()) {
       a.value = (char*) pstr->get_charstr();
    } else {
       a.value = "unknown";
    }
    args.push_back(a);

    a.id = UI_OS_VERSION;
    pstr = get_attr(IMDesktop::OS_VERSION);
    if (pstr && pstr->get_charstr()) {
       a.value = (char*) pstr->get_charstr();
    } else {
       a.value = "unknown";
    }
    args.push_back(a);

    a.id = UI_AUTH_PASSWD;
    // For security reason, currently
    // we don't pass a clear password to LE.
    a.value = NULL;
    args.push_back(a);

    return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void IMDesktop::get_lecontext_args ( vector< IMArg > &  args)

Definition at line 276 of file IMDesktop.cpp.

{
    IMArg a;

    //TODO!!!
    IMSetArg(a, SC_LOOKUP_LABELTYPE, "numeric");
    args.push_back(a);
    IMSetArg(a, SC_LOOKUP_NCOLS, 4);
    args.push_back(a);
    IMSetArg(a, SC_LOOKUP_NROWS, 4);
    args.push_back(a);

    return;
}

Here is the caller graph for this function:

bool IMDesktop::iiim_xbe_p ( ) const [inline]

Definition at line 69 of file IMDesktop.hh.

    { return iiim_xbe; }

Here is the caller graph for this function:

void IMDesktop::initialize ( ) [abstract, private]

Definition at line 15 of file IMDesktop.cpp.

{
    IMDesktopAttr::iterator it;

    iiim_xbe = false;

    it = attrs.find(CLIENT_NAME);
    if (it == attrs.end()) {
       client_type = UNKNOWN_CLIENT;
    } else {
       u16string& client_name = it->second;
       if (client_name.find("Htt XIM") != u16string::npos) {
           iiim_xbe = true;
           client_type = IIIMXCF;
       } else if (client_name.find("XBE XIM") != u16string::npos) {
           iiim_xbe = true;
           client_type = IIIMXCF;
       } else if (client_name.find("XIM IIIMP") != u16string::npos) {
           client_type = IIIMXCF;
       } else if (client_name.find("JDK") != u16string::npos) {
           client_type = IIIMJCF;
       } else if (client_name.find("GTK IIIMCF Module") != u16string::npos) {
           client_type = IIIMGCF;
       } else if (client_name.find("IIIMECF") != u16string::npos) {
           client_type = IIIMECF;
       }
    }

    // set alternative display_name.
    const u16string* pstr = get_attr(X_DISPLAY_NAME);
    if (pstr && pstr->get_charstr()) {
       desktop_display_name = pstr->get_charstr();
    } else {
       pstr = get_attr(CLIENT_HOST);
       if (!pstr) {
           LOG_ERROR("IMDesktop is requested, but the client host is unknown.");
       }
       if (pstr->get_charstr()) {
           desktop_display_name = pstr->get_charstr();
       } else {
           desktop_display_name = "unknown";
       }
       desktop_display_name.append(":0");
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 147 of file IMDesktop.cpp.

{
    IMDesktopAttr::iterator itr;
    IMDesktopAttr::iterator it;

    for (itr = req_attrs.begin(); itr != req_attrs.end(); itr++) {
       // need to compare client host and display names only
       if (itr->first == IMDesktop::CLIENT_HOST ||
           itr->first == IMDesktop::X_DISPLAY_NAME) {
         it = attrs.find(itr->first);
         if (it == attrs.end()) return false;
         if (it->second.compare(itr->second) != 0) return false;
       }
    }
    return true;
}

Here is the caller graph for this function:

void IMDesktop::release_iml_desktop ( LEContext lec,
iml_desktop_t iml_desktop 
)

Definition at line 113 of file IMDesktop.cpp.

{
    // TODO: need to pass command line option -desktop.
    // Use environment varialbe tentatively for now.
    static int iiimd_option_desktop;
    if (0 == iiimd_option_desktop) {
       if (NULL != getenv("IIIMD_OPTION_DESKTOP")) {
           iiimd_option_desktop = 1;
       } else {
           iiimd_option_desktop = -1;
       }
    }

    // TODO: Life-cycles of iml_desktop should be controlled by LEBase.
    // But it would involve redesign of LEbase.  Currently, the life-cycle
    // is reference of session.
    if (!iml_desktop->session_list) {
       LEBase *plebase = lec.get_lebase();
       IMLDesktopMap::iterator it = iml_desktop_map.find(plebase);
       ASSERT(it != iml_desktop_map.end());
       ASSERT(it->second == iml_desktop);
       plebase->close_iml_desktop(iml_desktop);
       del_user(iml_desktop);
       iml_desktop_map.erase(it);
       if ((1 == iiimd_option_desktop) && (0 == iml_desktop_map.size())) {
           kill(getpid(), SIGTERM);
       }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 90 of file IMDesktop.cpp.

{
    iml_desktop_t *pidt;
    LEBase *plebase = lec.get_lebase();
    IMLDesktopMap::iterator it = iml_desktop_map.find(plebase);
    if (it == iml_desktop_map.end()) {
       pidt = create_iml_desktop(lec);
       if (!pidt) return NULL;
       if (!plebase->open_iml_desktop(this, pidt)) {
           del_user(pidt);
           return NULL;
       }
       iml_desktop_map[plebase] = pidt;
    } else {
       pidt = it->second;
    }

    return pidt;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 36 of file IMDesktop.hh.

Definition at line 38 of file IMDesktop.hh.

bool IMDesktop::iiim_xbe [private]

Definition at line 37 of file IMDesktop.hh.

Definition at line 45 of file IMDesktop.hh.

Definition at line 35 of file IMDesktop.hh.


The documentation for this class was generated from the following files: