Back to index

im-sdk  12.3.91
IMConnection.cpp
Go to the documentation of this file.
00001 #include <config.h>
00002 #include <stdio.h>
00003 #include "IMConnection.hh"
00004 #include "IMInputContext.hh"
00005 #include "IMUser.hh"
00006 #include "IMDesktop.hh"
00007 #include "LEMgr.hh"
00008 
00009 IMDesktop*
00010 IMConnection::get_desktop()
00011 {
00012     if (pdesktop) return pdesktop;
00013 
00014     IMDesktop::IMDesktopAttr a;
00015     a[IMDesktop::CLIENT_HOST] = u16string(get_hostname());
00016     pdesktop = puser->request_desktop(a);
00017     return pdesktop;
00018 }
00019 
00020 /******************************************************************************
00021                    IMHandler implementation.
00022 ******************************************************************************/
00023 
00024 bool
00025 IMConnection::
00026 set_client_info(
00027     const IMHandler::ClientAttrList& attrlist
00028 )
00029 {
00030     IMDesktop::IMDesktopAttr a;
00031     IMHandler::ClientAttrList::const_iterator it;
00032 
00033     a[IMDesktop::CLIENT_HOST] = u16string(get_hostname());
00034     for (it = attrlist.begin(); it != attrlist.end(); it++) {
00035        switch (it->attr) {
00036          case IMHandler::CLIENT_NAME:
00037           a[IMDesktop::CLIENT_NAME] = it->val;
00038           break;
00039          case IMHandler::OS_NAME:
00040           a[IMDesktop::OS_NAME] = it->val;
00041           break;
00042          case IMHandler::OS_ARCH:
00043           a[IMDesktop::OS_ARCH] = it->val;
00044           break;
00045          case IMHandler::OS_VERSION:
00046           a[IMDesktop::OS_VERSION] = it->val;
00047           break;
00048          case IMHandler::X_DISPLAY_NAME:
00049           a[IMDesktop::X_DISPLAY_NAME] = it->val;
00050           break;
00051          case IMHandler::X_SERVER_VENDOR:
00052           a[IMDesktop::X_SERVER_VENDOR] = it->val;
00053           break;
00054          default:
00055           // simply ignore it.
00056           break;
00057        }
00058     }
00059     pdesktop = puser->request_desktop(a);
00060 
00061     return true;
00062 }
00063 
00064 bool
00065 IMConnection::get_triggerkeys(
00066     IMKeySpecList &onkeys,
00067     IMKeySpecList &offkeys
00068 )
00069 {
00070     IMKeySpec default_key(' ', ' ', 2, 0);
00071 
00072     const IMKeySpecList& ckeys = get_imsvr()->get_conversionkeys();
00073     if (ckeys.size() > 0) {
00074         for (IMKeySpecList::const_iterator it = ckeys.begin();
00075              it != ckeys.end();
00076              ++it) {
00077             onkeys.push_back(*it);
00078             offkeys.push_back(*it);
00079         }
00080     } else {
00081        onkeys.push_back(default_key);
00082        offkeys.push_back(default_key);
00083     }
00084 
00085     return true;
00086 }
00087 
00088 const IMLangList*
00089 IMConnection::get_langlist(
00090     iml_desktop_t *curr_desktop
00091 )
00092 {
00093     return get_lemgr()->get_all_langlist(curr_desktop);
00094 }
00095 
00096 const IMObjectWithDescList*
00097 IMConnection::get_imobjectdesclist()
00098 {
00099     return get_lemgr()->get_all_imobjectdesclist();
00100 }
00101 
00102 IMHotkeyProfileStruct*
00103 IMConnection::get_hotkey_profiles(int *count_profiles)
00104 {
00105   return get_lemgr()->get_hotkey_profiles(count_profiles);
00106 }
00107 
00108 const IMDescriptorList*
00109 IMConnection::get_imdesclist(
00110     iml_desktop_t *curr_desktop
00111 )
00112 {
00113     return get_lemgr()->get_all_imdesclist(curr_desktop);
00114 }
00115 
00116 const bool
00117 IMConnection::update_imdesclist(
00118     IMLEName *LEname,
00119     IMLocale *Locales,
00120     int nLocales
00121 )
00122 {
00123     return get_lemgr()->update_imdesclist(LEname, Locales, nLocales);
00124 }
00125 
00126 const IMObject*
00127 IMConnection::get_imobject(
00128     int attribid
00129 )
00130 {
00131     return NULL;
00132 }
00133 
00134 ICHandler*
00135 IMConnection::createic(
00136     ICAttribute &icattr
00137 )
00138 {
00139     IMInputContext *pic = new IMInputContext(this, icattr);
00140 
00141     // memory error.
00142     if (!pic) return NULL;
00143 
00144     return pic;
00145 }
00146 
00147 IMConnection::
00148 IMConnection(
00149     IMSvr *x_pimsvr,
00150     IMUser *x_puser,
00151     const string &x_hostname
00152 )
00153 {
00154     pimsvr = x_pimsvr;
00155     pdesktop = NULL;
00156     puser = x_puser;
00157     hostname = x_hostname;
00158     pdesktop = NULL;
00159 }
00160 
00161 IMConnection::~IMConnection()
00162 {
00163 }
00164 
00165 /* Local Variables: */
00166 /* c-file-style: "iiim-project" */
00167 /* End: */