diff options
| author | 2008-07-15 18:37:17 +0000 | |
|---|---|---|
| committer | 2008-07-15 18:37:17 +0000 | |
| commit | f2dada7b740c69e133d6ea073a593a7be277527e (patch) | |
| tree | f459c994f022ee00ae2f78d67a85fcb0cc8c973d /src/modules | |
| parent | nicknames have to be encoded with server encoding, not channel specific encod... (diff) | |
| download | KVIrc-f2dada7b740c69e133d6ea073a593a7be277527e.tar.gz KVIrc-f2dada7b740c69e133d6ea073a593a7be277527e.tar.bz2 KVIrc-f2dada7b740c69e133d6ea073a593a7be277527e.zip | |
Splitter server encoding in two pieces: server specific encoding (used to encode/decode channel names, nicknames, ..) and server default encoding for channels.
Made the some for networks, too; added configuration options and relative scripting commands/functions in serverdb's kvs.
Should definitely fix #173, and add better support for servers that expands the rfc 7-bit ansi table for channel, nicks, ...
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@2078 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src/modules')
| -rw-r--r-- | src/modules/options/optw_servers.cpp | 98 | ||||
| -rw-r--r-- | src/modules/options/optw_servers.h | 2 | ||||
| -rw-r--r-- | src/modules/serverdb/libkviserverdb.cpp | 98 |
3 files changed, 173 insertions, 25 deletions
diff --git a/src/modules/options/optw_servers.cpp b/src/modules/options/optw_servers.cpp index 010c22994..705efd2ec 100644 --- a/src/modules/options/optw_servers.cpp +++ b/src/modules/options/optw_servers.cpp @@ -78,6 +78,7 @@ KviNetworkDetailsWidget::KviNetworkDetailsWidget(QWidget * par,KviNetwork * n) m_pDescEditor=0; m_pEncodingEditor=0; + m_pTextEncodingEditor=0; m_pAutoConnectCheck=0; @@ -150,42 +151,64 @@ KviNetworkDetailsWidget::KviNetworkDetailsWidget(QWidget * par,KviNetwork * n) KviTalToolTip::add(m_pRealEditor,__tr2qs_ctx("<center>You can specify a \"special\" <b>real name</b> that will be used to login with the servers on this network.<br>" \ "If you leave this field empty (most common case), the default \"real name\" (specified in the \"Identity\" settings) will be used.</center>","options")); - l = new QLabel(__tr2qs_ctx("Encoding:","options"),tab); + //server encoding + + l = new QLabel(__tr2qs_ctx("Server Encoding:","options"),tab); gl->addWidget(l,1,0); m_pEncodingEditor = new QComboBox(tab); m_pEncodingEditor->setDuplicatesEnabled(false); gl->addWidget(m_pEncodingEditor,1,1); KviTalToolTip::add(m_pEncodingEditor,__tr2qs_ctx("<center>This box allows you to choose the preferred encoding for the servers in this network. " \ + "This encoding will be used for server specific needs, like referencing nicknames and channel names." \ + "If you choose \"Use System Encoding\" then the encoding will be set to the systemwide " \ + "value that you choose in the \"Encoding\" page of the options dialog.</center>","options")); + + //text encoding + + l = new QLabel(__tr2qs_ctx("Text Encoding:","options"),tab); + gl->addWidget(l,2,0); + m_pTextEncodingEditor = new QComboBox(tab); + m_pTextEncodingEditor->setDuplicatesEnabled(false); + gl->addWidget(m_pTextEncodingEditor,2,1); + KviTalToolTip::add(m_pTextEncodingEditor,__tr2qs_ctx("<center>This box allows you to choose the preferred encoding for the servers in this network. " \ + "This encoding will be used as the default for text messages." \ "If you choose \"Use System Encoding\" then the encoding will be set to the systemwide " \ "value that you choose in the \"Encoding\" page of the options dialog.</center>","options")); + //common between server encoding and text encoding + int i = 0; - int current = 0; + int srvcurrent = 0, txtcurrent=0; KviLocale::EncodingDescription * d = KviLocale::encodingDescription(i); QString tmp; m_pEncodingEditor->addItem(__tr2qs_ctx("Use System Encoding","options")); + m_pTextEncodingEditor->addItem(__tr2qs_ctx("Use System Encoding","options")); while(d->szName) { KviQString::sprintf(tmp,"%s (%s)",d->szName,d->szDescription); m_pEncodingEditor->insertItem(m_pEncodingEditor->count(),tmp); - if(KviQString::equalCI(d->szName,n->encoding()))current = i + 1; + m_pTextEncodingEditor->insertItem(m_pTextEncodingEditor->count(),tmp); + if(KviQString::equalCI(d->szName,n->encoding()))srvcurrent = i + 1; + if(KviQString::equalCI(d->szName,n->textEncoding()))txtcurrent = i + 1; i = i + 1; d = KviLocale::encodingDescription(i); } - m_pEncodingEditor->setCurrentIndex(current); + m_pEncodingEditor->setCurrentIndex(srvcurrent); + m_pTextEncodingEditor->setCurrentIndex(txtcurrent); + m_pAutoConnectCheck = new QCheckBox(__tr2qs_ctx("Connect to this network at startup","options"),tab); m_pAutoConnectCheck->setChecked(n->autoConnect()); - gl->addWidget(m_pAutoConnectCheck,2,0,1,2); + gl->addWidget(m_pAutoConnectCheck,3,0,1,2); // gl->addMultiCellWidget(m_pAutoConnectCheck,2,2,0,1); KviTalToolTip::add(m_pAutoConnectCheck,__tr2qs_ctx("<center>This option will cause KVIrc to automatically connect to this network at startup</center>","options")); l = new QLabel("",tab); - gl->addWidget(l,3,0); + gl->addWidget(l,4,0); - gl->setRowStretch(3,1); + gl->setRowStretch(4,1); gl->setColumnStretch(1,1); tw->addTab(tab,__tr2qs_ctx("General","options")); @@ -387,6 +410,12 @@ void KviNetworkDetailsWidget::fillData(KviNetwork * n) KviLocale::EncodingDescription * d = KviLocale::encodingDescription(m_pEncodingEditor->currentIndex() - 1); n->setEncoding(d->szName); } + if(m_pTextEncodingEditor) + if(m_pTextEncodingEditor->currentIndex() <= 0)n->setTextEncoding(QString::null); + else { + KviLocale::EncodingDescription * dd = KviLocale::encodingDescription(m_pTextEncodingEditor->currentIndex() - 1); + n->setTextEncoding(dd->szName); + } if(m_pChannelListSelector) m_pChannelListSelector->commit(); if(m_lstChannels.isEmpty())n->setAutoJoinChannelList(0); @@ -608,38 +637,59 @@ KviServerDetailsWidget::KviServerDetailsWidget(QWidget * par,KviServer * s) // gl->addMultiCellWidget(m_pUseAutoConnect,5,5,0,1); KviTalToolTip::add(m_pUseAutoConnect,__tr2qs_ctx("<center>This option will cause KVIrc to connect to the IRC server when it is started.</center>","options")); - l = new QLabel(__tr2qs_ctx("Encoding:","options"),tab); + //server encoding + + l = new QLabel(__tr2qs_ctx("Server Encoding:","options"),tab); gl->addWidget(l,6,0); m_pEncodingEditor = new QComboBox(tab); m_pEncodingEditor->setDuplicatesEnabled(false); gl->addWidget(m_pEncodingEditor,6,1); - KviTalToolTip::add(m_pEncodingEditor,__tr2qs_ctx("<center>This box allows you to choose the preferred encoding for this sever. " \ + KviTalToolTip::add(m_pEncodingEditor,__tr2qs_ctx("<center>This box allows you to choose the preferred encoding for this server. " \ + "This encoding will be used for server specific needs, like referencing nicknames and channel names." \ + "If you choose \"Use Network Encoding\" then the encoding will be inherited from the " \ + "network that this server belongs to.</center>","options")); + + //text encoding + + l = new QLabel(__tr2qs_ctx("Text Encoding:","options"),tab); + gl->addWidget(l,7,0); + m_pTextEncodingEditor = new QComboBox(tab); + m_pTextEncodingEditor->setDuplicatesEnabled(false); + gl->addWidget(m_pTextEncodingEditor,7,1); + KviTalToolTip::add(m_pEncodingEditor,__tr2qs_ctx("<center>This box allows you to choose the preferred encoding for this server. " \ + "This encoding will be used as the default for text messages." \ "If you choose \"Use Network Encoding\" then the encoding will be inherited from the " \ "network that this server belongs to.</center>","options")); + //common between server encoding and text encoding + int i = 0; - int current = 0; + int srvcurrent = 0, txtcurrent=0; KviLocale::EncodingDescription * d = KviLocale::encodingDescription(i); QString tmp; m_pEncodingEditor->addItem(__tr2qs_ctx("Use Network Encoding","options")); + m_pTextEncodingEditor->addItem(__tr2qs_ctx("Use Network Encoding","options")); while(d->szName) { KviQString::sprintf(tmp,"%s (%s)",d->szName,d->szDescription); m_pEncodingEditor->insertItem(m_pEncodingEditor->count(),tmp); - if(KviQString::equalCI(d->szName,s->encoding()))current = i + 1; + m_pTextEncodingEditor->insertItem(m_pTextEncodingEditor->count(),tmp); + if(KviQString::equalCI(d->szName,s->encoding()))srvcurrent = i + 1; + if(KviQString::equalCI(d->szName,s->textEncoding()))txtcurrent = i + 1; i = i + 1; d = KviLocale::encodingDescription(i); } - m_pEncodingEditor->setCurrentIndex(current); + m_pEncodingEditor->setCurrentIndex(srvcurrent); + m_pTextEncodingEditor->setCurrentIndex(txtcurrent); l = new QLabel(__tr2qs_ctx("Link filter:","options"),tab); - gl->addWidget(l,7,0); + gl->addWidget(l,8,0); m_pLinkFilterEditor = new QComboBox(tab); m_pLinkFilterEditor->setEditable(true); m_pLinkFilterEditor->setDuplicatesEnabled(false); - gl->addWidget(m_pLinkFilterEditor,7,1); + gl->addWidget(m_pLinkFilterEditor,8,1); m_pLinkFilterEditor->addItem(""); @@ -674,11 +724,11 @@ KviServerDetailsWidget::KviServerDetailsWidget(QWidget * par,KviServer * s) "For plain IRC connections, you don't need any link filters; this is used for incompatible protocols.</center>","options")); l = new QLabel(__tr2qs_ctx("Id:","options"),tab); - gl->addWidget(l,8,0); + gl->addWidget(l,9,0); m_pIdEditor = new QLineEdit(tab); if(s->id().isEmpty())s->generateUniqueId(); m_pIdEditor->setText(s->id()); - gl->addWidget(m_pIdEditor,8,1); + gl->addWidget(m_pIdEditor,9,1); KviTalToolTip::add(m_pIdEditor,__tr2qs_ctx("<center>This field allows you to specify a really unique id for this server. " \ "You will then be able to use /server -x <this_id> to make the connection. This is especially " \ @@ -686,10 +736,10 @@ KviServerDetailsWidget::KviServerDetailsWidget(QWidget * par,KviServer * s) l = new QLabel(__tr2qs_ctx("Proxy server:","options"),tab); - gl->addWidget(l,9,0); + gl->addWidget(l,10,0); m_pProxyEditor = new QComboBox(tab); - gl->addWidget(m_pProxyEditor,9,1); - KviTalToolTip::add(m_pProxyEditor,__tr2qs_ctx("<center>This is the <b>proxy</b> that KVIrc will use to connect to thos server.\n" \ + gl->addWidget(m_pProxyEditor,10,1); + KviTalToolTip::add(m_pProxyEditor,__tr2qs_ctx("<center>This is the <b>proxy</b> that KVIrc will use to connect to this server.\n" \ "If this field is set in \"Default\" KVirc will use global proxy settings, if it is set in \"Direct connection\" " \ "KVirc will connect to this server without proxy. You can define new proxy server in global options' \"Proxy servers\" menu.</center>","options")); @@ -706,10 +756,10 @@ KviServerDetailsWidget::KviServerDetailsWidget(QWidget * par,KviServer * s) l = new QLabel("",tab); - gl->addWidget(l,10,0,1,2); + gl->addWidget(l,11,0,1,2); // gl->addMultiCellWidget(l,10,10,0,1); - gl->setRowStretch(10,1); + gl->setRowStretch(11,1); tw->addTab(tab,*(g_pIconManager->getSmallIcon(KVI_SMALLICON_SOCKETWARNING)),__tr2qs_ctx("Connection","options")); @@ -839,6 +889,12 @@ void KviServerDetailsWidget::fillData(KviServer * s) KviLocale::EncodingDescription * d = KviLocale::encodingDescription(m_pEncodingEditor->currentIndex() - 1); s->m_szEncoding = d->szName; } + if(m_pTextEncodingEditor) + if(m_pTextEncodingEditor->currentIndex() <= 0)s->m_szTextEncoding = ""; + else { + KviLocale::EncodingDescription * dd = KviLocale::encodingDescription(m_pTextEncodingEditor->currentIndex() - 1); + s->m_szTextEncoding = dd->szName; + } s->setIp(""); if(m_pCacheIpCheck) s->setCacheIp(m_pCacheIpCheck->isChecked()); diff --git a/src/modules/options/optw_servers.h b/src/modules/options/optw_servers.h index a64e992f5..98d46b5c7 100644 --- a/src/modules/options/optw_servers.h +++ b/src/modules/options/optw_servers.h @@ -81,6 +81,7 @@ protected: QLineEdit * m_pDescEditor; QComboBox * m_pEncodingEditor; + QComboBox * m_pTextEncodingEditor; QCheckBox * m_pAutoConnectCheck; @@ -120,6 +121,7 @@ protected: QLineEdit * m_pIdEditor; QComboBox * m_pLinkFilterEditor; QComboBox * m_pEncodingEditor; + QComboBox * m_pTextEncodingEditor; KviIpEditor * m_pIpEditor; QCheckBox * m_pCacheIpCheck; QCheckBox * m_pUseSSLCheck; diff --git a/src/modules/serverdb/libkviserverdb.cpp b/src/modules/serverdb/libkviserverdb.cpp index e88da3808..b92a63fcc 100644 --- a/src/modules/serverdb/libkviserverdb.cpp +++ b/src/modules/serverdb/libkviserverdb.cpp @@ -283,13 +283,30 @@ SERVERDB_GET_NETWORK_PROPERTY(serverdb_kvs_fnc_getNetworkRealName,realName) @synthax: <string> $serverdb.getNetworkEncoding(<string:network>) @description: - Returns the encoding set for the network <network> if set + Returns the encoding used for the network <network> for server specific messages, like channel and nick names, if set @seealso: [module:serverdb]ServerDB module documentation[/module] */ SERVERDB_GET_NETWORK_PROPERTY(serverdb_kvs_fnc_getNetworkEncoding,encoding) /* + @doc: serverdb.getNetworkTextEncoding + @type: + function + @title: + $serverdb.getNetworkTextEncoding + @short: + Returns the encoding + @synthax: + <string> $serverdb.getNetworkTextEncoding(<string:network>) + @description: + Returns the encoding used for the network <network> for text messages, if set + @seealso: + [module:serverdb]ServerDB module documentation[/module] +*/ +SERVERDB_GET_NETWORK_PROPERTY(serverdb_kvs_fnc_getNetworkTextEncoding,textEncoding) + +/* @doc: serverdb.getNetworkDescription @type: function @@ -419,13 +436,30 @@ SERVERDB_GET_SERVER_PROPERTY(serverdb_kvs_fnc_getServerRealName,realName,setStri @synthax: <string> $serverdb.getServerEncoding(<string:network>,<string:server>) @description: - Returns the encoding set for the server <server> of the network <network> if set + Returns the encoding used for the server <server> of the network <network> for server specific messages, like channel and nick names, if set @seealso: [module:serverdb]ServerDB module documentation[/module] */ SERVERDB_GET_SERVER_PROPERTY(serverdb_kvs_fnc_getServerEncoding,encoding,setString) /* + @doc: serverdb.getServerTextEncoding + @type: + function + @title: + $serverdb.getServerTextEncoding + @short: + Returns the encoding + @synthax: + <string> $serverdb.getServerTextEncoding(<string:network>,<string:server>) + @description: + Returns the encoding used for the server <server> of the network <network> for server specific messages, like channel and nick names, if set + @seealso: + [module:serverdb]ServerDB module documentation[/module] +*/ +SERVERDB_GET_SERVER_PROPERTY(serverdb_kvs_fnc_getServerTextEncoding,textEncoding,setString) + +/* @doc: serverdb.getServerDescription @type: function @@ -949,7 +983,8 @@ SERVERDB_SET_NETWORK_PROPERTY(serverdb_kvs_cmd_setNetworkRealName,setRealName) @syntax: serverdb.setNetworkEncoding [switches] <string:name> <string:encoding> @description: - Sets the encoding <encoding> for the specified network <name>. + Sets the encoding <encoding> for the specified network <name>. This encoding will be used for server-specific + text, like channel names and nicknames. @switches: !sw: -q | --quiet Do not print errors if the network already exists. @@ -964,6 +999,31 @@ SERVERDB_SET_NETWORK_PROPERTY(serverdb_kvs_cmd_setNetworkRealName,setRealName) SERVERDB_SET_NETWORK_PROPERTY(serverdb_kvs_cmd_setNetworkEncoding,setEncoding) /* + @doc: serverdb.setNetworkTextEncoding + @type: + command + @title: + serverdb.setNetworkTextEncoding + @short: + Sets the encoding + @syntax: + serverdb.setNetworkTextEncoding [switches] <string:name> <string:encoding> + @description: + Sets the encoding <encoding> for the specified network <name>. This encoding will be used for text messages. + @switches: + !sw: -q | --quiet + Do not print errors if the network already exists. + @examples: + [example] + [comment]Quietly sets the text encoding UTF-8 for the Freenode network[/comment][br] + serverdb.setNetworkTextEncoding -q Freenode UTF-8 + [/example] + @seealso: + [module:serverdb]ServerDB module documentation[/module] +*/ +SERVERDB_SET_NETWORK_PROPERTY(serverdb_kvs_cmd_setNetworkTextEncoding,setTextEncoding) + +/* @doc: serverdb.setNetworkDescription @type: command @@ -1124,7 +1184,8 @@ SERVERDB_SET_SERVER_PROPERTY(serverdb_kvs_cmd_setServerRealName,setRealName) @syntax: serverdb.setServerEncoding [switches] <string:name> <string:encoding> @description: - Sets the encoding <encoding> for the specified server <name>. + Sets the encoding <encoding> for the specified server <name>. This encoding will be used for server-specific + text, like channel names and nicknames. @switches: !sw: -q | --quiet Do not print errors if the server already exists. @@ -1139,6 +1200,31 @@ SERVERDB_SET_SERVER_PROPERTY(serverdb_kvs_cmd_setServerRealName,setRealName) SERVERDB_SET_SERVER_PROPERTY(serverdb_kvs_cmd_setServerEncoding,setEncoding) /* + @doc: serverdb.setServerTextEncoding + @type: + command + @title: + serverdb.setServerTextEncoding + @short: + Sets the text encoding + @syntax: + serverdb.setServerTextEncoding [switches] <string:name> <string:encoding> + @description: + Sets the encoding <encoding> for the specified server <name>. This encoding will be used for text messages. + @switches: + !sw: -q | --quiet + Do not print errors if the server already exists. + @examples: + [example] + [comment]Quietly sets the text encoding UTF-8 for the irc.freenode.net server[/comment][br] + serverdb.setServerTextEncoding -q Freenode UTF-8 + [/example] + @seealso: + [module:serverdb]ServerDB module documentation[/module] +*/ +SERVERDB_SET_SERVER_PROPERTY(serverdb_kvs_cmd_setServerTextEncoding,setTextEncoding) + +/* @doc: serverdb.setServerDescription @type: command @@ -1223,6 +1309,7 @@ static bool serverdb_module_init(KviModule * m) KVSM_REGISTER_FUNCTION(m,"getNetworkConnectCommand",serverdb_kvs_fnc_getNetworkConnectCommand); KVSM_REGISTER_FUNCTION(m,"getNetworkDescription",serverdb_kvs_fnc_getNetworkDescription); KVSM_REGISTER_FUNCTION(m,"getNetworkEncoding",serverdb_kvs_fnc_getNetworkEncoding); + KVSM_REGISTER_FUNCTION(m,"getNetworkTextEncoding",serverdb_kvs_fnc_getNetworkTextEncoding); KVSM_REGISTER_FUNCTION(m,"getNetworkLoginCommand",serverdb_kvs_fnc_getNetworkLoginCommand); KVSM_REGISTER_FUNCTION(m,"getNetworkName",serverdb_kvs_fnc_getNetworkName); KVSM_REGISTER_FUNCTION(m,"getNetworkNickName",serverdb_kvs_fnc_getNetworkNickName); @@ -1231,6 +1318,7 @@ static bool serverdb_module_init(KviModule * m) KVSM_REGISTER_FUNCTION(m,"getServerConnectCommand",serverdb_kvs_fnc_getServerConnectCommand); KVSM_REGISTER_FUNCTION(m,"getServerDescription",serverdb_kvs_fnc_getServerDescription); KVSM_REGISTER_FUNCTION(m,"getServerEncoding",serverdb_kvs_fnc_getServerEncoding); + KVSM_REGISTER_FUNCTION(m,"getServerTextEncoding",serverdb_kvs_fnc_getServerTextEncoding); KVSM_REGISTER_FUNCTION(m,"getServerId",serverdb_kvs_fnc_getServerId) KVSM_REGISTER_FUNCTION(m,"getServerIp",serverdb_kvs_fnc_getServerIp) KVSM_REGISTER_FUNCTION(m,"getServerLoginCommand",serverdb_kvs_fnc_getServerLoginCommand); @@ -1249,6 +1337,7 @@ static bool serverdb_module_init(KviModule * m) KVSM_REGISTER_SIMPLE_COMMAND(m,"addServer",serverdb_kvs_cmd_addServer); KVSM_REGISTER_SIMPLE_COMMAND(m,"setNetworkConnectCommand",serverdb_kvs_cmd_setNetworkConnectCommand); KVSM_REGISTER_SIMPLE_COMMAND(m,"setNetworkEncoding",serverdb_kvs_cmd_setNetworkEncoding); + KVSM_REGISTER_SIMPLE_COMMAND(m,"setNetworkTextEncoding",serverdb_kvs_cmd_setNetworkTextEncoding); KVSM_REGISTER_SIMPLE_COMMAND(m,"setNetworkDescription",serverdb_kvs_cmd_setNetworkDescription); KVSM_REGISTER_SIMPLE_COMMAND(m,"setNetworkLoginCommand",serverdb_kvs_cmd_setNetworkLoginCommand); KVSM_REGISTER_SIMPLE_COMMAND(m,"setNetworkNickName",serverdb_kvs_cmd_setNetworkNickName); @@ -1256,6 +1345,7 @@ static bool serverdb_module_init(KviModule * m) KVSM_REGISTER_SIMPLE_COMMAND(m,"setNetworkUserName",serverdb_kvs_cmd_setNetworkUserName); KVSM_REGISTER_SIMPLE_COMMAND(m,"setServerConnectCommand",serverdb_kvs_cmd_setServerConnectCommand); KVSM_REGISTER_SIMPLE_COMMAND(m,"setServerEncoding",serverdb_kvs_cmd_setServerEncoding); + KVSM_REGISTER_SIMPLE_COMMAND(m,"setServerTextEncoding",serverdb_kvs_cmd_setServerTextEncoding); KVSM_REGISTER_SIMPLE_COMMAND(m,"setServerDescription",serverdb_kvs_cmd_setServerDescription); KVSM_REGISTER_SIMPLE_COMMAND(m,"setServerLoginCommand",serverdb_kvs_cmd_setServerLoginCommand); KVSM_REGISTER_SIMPLE_COMMAND(m,"setServerNickName",serverdb_kvs_cmd_setServerNickName); |
