Warning, file /games/kmuddy/plugins/converter/cconnprefs.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /*************************************************************************** 0002 cconnprefs.cpp - connection preferences, aliases, ... 0003 This file is a part of KMuddy distribution. 0004 ------------------- 0005 begin : Po Jul 22 2002 0006 copyright : (C) 2002-2005 by Tomas Mecir 0007 email : kmuddy@kmuddy.com 0008 ***************************************************************************/ 0009 0010 /*************************************************************************** 0011 * * 0012 * This program is free software; you can redistribute it and/or modify * 0013 * it under the terms of the GNU General Public License as published by * 0014 * the Free Software Foundation; either version 2 of the License, or * 0015 * (at your option) any later version. * 0016 * * 0017 ***************************************************************************/ 0018 0019 #include "cconnprefs.h" 0020 0021 #include <qdir.h> 0022 #include <kconfig.h> 0023 #include <kconfiggroup.h> 0024 0025 cConnPrefs::cConnPrefs (QString dir) 0026 { 0027 directory = dir; 0028 } 0029 0030 cConnPrefs::~cConnPrefs() 0031 { 0032 } 0033 0034 void cConnPrefs::load () 0035 { 0036 //prepare configfile 0037 KConfig *config = new KConfig (directory + "/preferences"); 0038 0039 //load basic info 0040 KConfigGroup g = config->group ("General"); 0041 setServer (g.readEntry ("Server", "")); 0042 setPort (g.readEntry ("Port", 0)); 0043 setLogin (g.readEntry ("Login", "")); 0044 setPassword (g.readEntry ("Password", "")); 0045 0046 //login sequence 0047 g = config->group ("Login sequence"); 0048 _connstr.clear (); 0049 int lsc = g.readEntry ("Count", 0); 0050 for (int i = 1; i <= lsc; i++) 0051 { 0052 QString s = g.readEntry ("Line " + QString::number(i), QString()); 0053 _connstr.append (s); 0054 } 0055 if (lsc == 0) //default login sequence 0056 { 0057 _connstr.append ("$name"); 0058 _connstr.append ("$password"); 0059 } 0060 0061 //connection parameters 0062 g = config->group ("Connection"); 0063 setAnsiColors (g.readEntry ("ANSI Colors", true)); 0064 setLimitTriggers (g.readEntry ("Limit triggers", true)); 0065 setLimitRepeater (g.readEntry ("Limit repeater", true)); 0066 setNegotiateOnStartup (g.readEntry ("Negotiate on startup", true)); 0067 setPromptLabel (g.readEntry ("Prompt label", false)); 0068 setLPMudStyle (g.readEntry ("LPMud style", false)); 0069 setStatusPrompt (g.readEntry ("Status prompt", false)); 0070 setConsolePrompt (g.readEntry ("Console prompt", true)); 0071 setAutoAdvTranscript (g.readEntry ("Auto logging", false)); 0072 0073 //commands 0074 g = config->group ("Commands"); 0075 setCmd (North, g.readEntry ("North", "n")); 0076 setCmd (NorthEast, g.readEntry ("NorthEast", "ne")); 0077 setCmd (East, g.readEntry ("East", "e")); 0078 setCmd (SouthEast, g.readEntry ("SouthEast", "se")); 0079 setCmd (South, g.readEntry ("South", "s")); 0080 setCmd (SouthWest, g.readEntry ("SouthWest", "sw")); 0081 setCmd (West, g.readEntry ("West", "w")); 0082 setCmd (NorthWest, g.readEntry ("NorthWest", "nw")); 0083 setCmd (Up, g.readEntry ("Up", "u")); 0084 setCmd (Down, g.readEntry ("Down", "d")); 0085 setQuit (g.readEntry ("Quit", "quit")); 0086 0087 //scripts 0088 g = config->group ("Scripts"); 0089 setScriptDir (g.readEntry ("Script directory", QDir::homePath())); 0090 setWorkDir (g.readEntry ("Working directory", QDir::homePath())); 0091 0092 //directories (the above two should go here, but we don't want to corrupt 0093 // existing settings) 0094 g = config->group ("Directories"); 0095 setTranscriptDir (g.readEntry ("Transcript directory", QDir::homePath())); 0096 0097 //MSP 0098 g = config->group ("Sound Protocol"); 0099 sounddirs.clear (); 0100 setUseMSP (g.readEntry ("Use MSP", true)); 0101 setAlwaysMSP (g.readEntry ("Always MSP", false)); 0102 setMidlineMSP (g.readEntry ("Midline MSP", false)); 0103 int count = g.readEntry ("Path count", -1); 0104 if (count == -1) 0105 { 0106 //default sound dirs 0107 count = 1; 0108 sounddirs << QDir::homePath() + "/sounds"; 0109 } 0110 else 0111 for (int i = 1; i <= count; i++) 0112 sounddirs << g.readEntry (QString("Path ") + QString::number(i), 0113 QString()); 0114 0115 //MXP 0116 g = config->group ("MUD Extension Protocol"); 0117 //how to use MXP? By default, we auto-detect it (i.e., we parse for MXP stuff, but we 0118 //remain in LOCKED mode by default, until changed by server) 0119 setUseMXP (g.readEntry ("Use MXP", 3)); 0120 varprefix = g.readEntry ("Variable prefix", ""); 0121 0122 delete config; 0123 0124 } 0125 0126 //some functions that get/set preferences; most of them are in header file 0127 0128 void cConnPrefs::setPort (int port) 0129 { 0130 if ((port > 0) && (port <= 65535)) 0131 _port = port; 0132 } 0133 0134 void cConnPrefs::setAnsiColors (bool val) 0135 { 0136 _ansicolors = val; 0137 } 0138 0139 void cConnPrefs::setCmd (int which, QString val) 0140 { 0141 if ((which >= 0) && (which <= 9)) 0142 _cmd[which] = val; 0143 } 0144 0145 void cConnPrefs::setQuit (QString val) 0146 { 0147 _cmdquit = val; 0148 } 0149 0150 void cConnPrefs::setPromptLabel (bool val) 0151 { 0152 _promptlabel = val; 0153 0154 } 0155 0156 void cConnPrefs::setNegotiateOnStartup (bool val) 0157 { 0158 _startupneg = val; 0159 } 0160 0161 void cConnPrefs::setLPMudStyle(bool val) 0162 { 0163 _lpmudstyle = val; 0164 } 0165 0166 void cConnPrefs::setStatusPrompt(bool val) 0167 { 0168 _statusprompt = val; 0169 } 0170 0171 void cConnPrefs::setUseMXP (int val) 0172 { 0173 usemxp = val; 0174 } 0175 0176