/*************************************************************************** * Read the settings from the file ***************************************************************************/ void setup::read(){ KConfig &config = *KGlobal::config(); config.setGroup("chatwindow"); int i, r, g, b; bool convertoldfiles = false; //Get File Name //qDebug("setup::read() i_currentSettings->login_name %s\n", i_currentSettings->login_name.latin1()); QString kinkattaDirStr = KINKATTA_DIR; QString qtkinkattaDir; QDir kinkattaDir(kinkattaDirStr); //Make Dir bool madeKinkattaDir = false; if( !kinkattaDir.exists() ){ // if no kdeDir and qt dir (~/.kinkatta) exists then copy settings to kdeDir qtkinkattaDir = QT_KINKATTA_DIR; if(QFile::exists(qtkinkattaDir)) { // copy qt settings to kdedir KShellProcess *shell = new KShellProcess(); *shell << "cp"; *shell << "-r"; *shell << qtkinkattaDir.latin1(); *shell << kinkattaDirStr.latin1(); shell->start( KProcess::Block ); } else { madeKinkattaDir = true; kinkattaDir.mkdir(kinkattaDirStr, true); } } QString settingsFileXml = kinkattaDirStr; settingsFileXml += "settings.xml"; if(!QFile::exists(settingsFileXml)){ //both xml and old prefs files dont exist //There is a .kinkatta folder but no xml file, convert //XXX: temporary if (madeKinkattaDir == false){ // set flag so conversion can be done after defaults load convertoldfiles = true; } } Preferences prefs(settingsFileXml, QString("kinkatta prefs"), QString("1.0")); r = g = b = 0; prefs.setGroup("sound"); i_currentSettings->SoundMode= prefs.getNumber("SoundMode", 1); i_currentSettings->sound_enable_login = prefs.getBool("sound_enable_login", true); i_currentSettings->sound_enable_logout= prefs.getBool("sound_enable_logout", false ); i_currentSettings->sound_file_command= prefs.getString("sound_file_command", "artsplay" ); i_currentSettings->sound_file_login= prefs.getString("sound_file_login", DATADIR "/sounds/BuddyArrive.au"); i_currentSettings->sound_file_logout= prefs.getString("sound_file_logout", DATADIR "/sounds/BuddyLeave.au"); prefs.setGroup("network"); i_currentSettings->login_server_toc = prefs.getString("login_server_toc", "toc.oscar.aol.com"); i_currentSettings->login_server_login= prefs.getString("login_server_login", "login.oscar.aol.com"); i_currentSettings->login_port_toc= prefs.getString("login_port_toc", "9898"); i_currentSettings->login_port_login= prefs.getString("login_port_login", "5190"); i_currentSettings->login_enable_auto= prefs.getBool("login_enable_auto", false); i_currentSettings->login_name = prefs.getString("login_name", "<new user>"); i_currentSettings->proxy_Choice= prefs.getNumber("proxy_Choice", 0); i_currentSettings->proxy_server = prefs.getString("proxy_server", ""); i_currentSettings->proxy_port = prefs.getString("proxy_port", ""); prefs.setGroup("away"); i_currentSettings->away_enable_auto= prefs.getBool("away_enable_auto" , false); i_currentSettings->away_comeBackOnlyOnBackClick= prefs.getBool("away_comeBackOnlyOnBackClick" , false); i_currentSettings->away_disable_sound= prefs.getBool("away_disable_sound" , false); i_currentSettings->away_auto_delay_minutes= prefs.getNumber("away_auto_delay_minutes", 30); i_currentSettings->away_auto_default_message= prefs.getString("away_auto_default_message", "Away"); i_currentSettings->ignore_automated_get_away= prefs.getBool("ignore_automated_get_away", true); prefs.setGroup("general"); i_currentSettings->main_resizeHeight= prefs.getBool("main_resizeHeight", false); i_currentSettings->main_resizeHeightMax= prefs.getNumber("main_resizeHeightMax", 600); i_currentSettings->main_resizeHeightMin= prefs.getNumber("main_resizeHeightMin", 200); i_currentSettings->main_resizeWidth= prefs.getBool("main_resizeWidth", true); i_currentSettings->main_resizeWidthMax= prefs.getNumber("main_resizeWidthMax", 300); i_currentSettings->main_resizeWidthMin= prefs.getNumber("main_resizeWidthMin", 50); i_currentSettings->main_loginMoveRight= prefs.getBool("main_loginMoveRight", false); i_currentSettings->main_loginMoveLeft= prefs.getBool("main_loginMoveLeft", false); i_currentSettings->main_loginMoveNo = prefs.getBool("main_loginMoveNo", true); i_currentSettings->main_showIdle= prefs.getBool("main_showIdle", true); i_currentSettings->main_showLastOn= prefs.getBool("main_showLastOn", false); i_currentSettings->main_noIcons= prefs.getBool("main_noIcons", false); i_currentSettings->main_moveDown= prefs.getNumber("main_moveDown", 0); i_currentSettings->main_idleLayout= prefs.getNumber("main_idleLayout", 0); i_currentSettings->main_noHeader= prefs.getBool("main_noHeader", false); i_currentSettings->main_useX11ForIdle= prefs.getBool("main_useX11ForIdle", false ); i_currentSettings->main_showTraySignonTooltip= prefs.getBool("main_showTraySignonTooltip", true ); i_currentSettings->main_traySignonTooltipPosX= prefs.getNumber("main_traySignonTooltipPosX", 0 ); i_currentSettings->main_traySignonTooltipPosY= prefs.getNumber("main_traySignonTooltipPosY", 0 ); i_currentSettings->main_traySignonTooltipAnchorPosition= prefs.getNumber("main_traySignonTooltipAnchorPosition", 0 ); i_currentSettings->main_mute_on_login= prefs.getBool("main_mute_on_login", true ); i_currentSettings->xSize= prefs.getNumber("xSize", -1); i_currentSettings->ySize= prefs.getNumber("ySize", -1); prefs.setGroup("chat"); bool chat_raise_window; // Done bool chat_flash_on_new_message; // Done bool chat_log; // Done bool chat_log_inHtml; // Done bool chat_show_time; // Done bool chat_log_time; // Done bool chat_return_send; // Done bool chat_sreturn_send; // Done bool chat_send_blank; // Done bool chat_ignore_contacthtml; // Done bool chat_line_limit; // Done bool chat_show_smilies; // Done int chat_line_limit_number; // Done bool chat_log_singleFile; chat_raise_window= config.readBoolEntry("chat_raise_window", true); chat_flash_on_new_message = config.readBoolEntry("chat_flash_on_new_message", true); chat_log = config.readBoolEntry("chat_log", true); chat_log_inHtml= config.readBoolEntry("chat_log_inHtml", true); chat_show_time = config.readBoolEntry("chat_show_time", true); chat_log_time= config.readBoolEntry("chat_log_time", true); chat_return_send= config.readBoolEntry("chat_return_send", true); chat_sreturn_send= config.readBoolEntry("chat_sreturn_send", false); chat_send_blank= config.readBoolEntry("chat_send_blank", false); chat_ignore_contacthtml= config.readBoolEntry("chat_ignore_buddyhtml", false); chat_show_smilies= config.readBoolEntry("chat_show_smilies", true); chat_line_limit= config.readBoolEntry("chat_line_limit", false); chat_line_limit_number= config.readNumEntry("chat_line_limit_number",200 ); chat_log_singleFile= config.readBoolEntry("chat_log_singleFile", false); chat_raise_window= prefs.getBool("chat_raise_window", chat_raise_window); chat_flash_on_new_message = prefs.getBool("chat_flash_on_new_message", chat_flash_on_new_message); chat_log = prefs.getBool("chat_log", chat_log); chat_log_inHtml= prefs.getBool("chat_log_inHtml", chat_log_inHtml); chat_show_time = prefs.getBool("chat_show_time", chat_show_time); chat_log_time= prefs.getBool("chat_log_time", chat_log_time); chat_return_send= prefs.getBool("chat_return_send", chat_return_send); chat_sreturn_send= prefs.getBool("chat_sreturn_send", chat_sreturn_send); chat_send_blank= prefs.getBool("chat_send_blank", chat_send_blank); chat_ignore_contacthtml= prefs.getBool("chat_ignore_buddyhtml", chat_ignore_contacthtml); chat_show_smilies= prefs.getBool("chat_show_smilies", chat_show_smilies); chat_line_limit= prefs.getBool("chat_line_limit", chat_line_limit); chat_line_limit_number= prefs.getNumber("chat_line_limit_number",chat_line_limit_number ); chat_log_singleFile= prefs.getBool("chat_log_singleFile", chat_log_singleFile); config.writeEntry("chat_raise_window", chat_raise_window); config.writeEntry("chat_flash_on_new_message", chat_flash_on_new_message); config.writeEntry("chat_log", chat_log); config.writeEntry("chat_log_inHtml",chat_log_inHtml ); config.writeEntry("chat_log_singleFile", chat_log_singleFile); config.writeEntry("chat_show_time", chat_show_time); config.writeEntry("chat_log_time", chat_log_time); config.writeEntry("chat_return_send", chat_return_send); config.writeEntry("chat_sreturn_send", chat_sreturn_send); config.writeEntry("chat_send_blank", chat_send_blank); config.writeEntry("chat_ignore_contacthtml", chat_ignore_contacthtml); config.writeEntry("chat_show_smilies", chat_show_smilies); config.writeEntry("chat_line_limit", chat_line_limit); config.writeEntry("chat_line_limit_number", chat_line_limit_number); config.writeEntry("chat_log", chat_log); QColor chat_yourText_color; // Done QColor chat_yourName_color; // Done QColor chat_contactText_color; // Done QColor chat_contactName_color; // Done QColor chat_yourbg_color; // Done QColor chat_contactbg_color; // Done r = config.readNumEntry("chat_yourText_color.R", 0); g = config.readNumEntry("chat_yourText_color.G", 0); b = config.readNumEntry("chat_yourText_color.B", 0); r = prefs.getNumber("chat_yourText_color.R", r); g = prefs.getNumber("chat_yourText_color.G", g); b = prefs.getNumber("chat_yourText_color.B", b); chat_yourText_color.setRgb(r, g, b); r = config.readNumEntry("chat_yourName_color.R", 0); g = config.readNumEntry("chat_yourName_color.G", 60); b = config.readNumEntry("chat_yourName_color.B", 128); r = prefs.getNumber("chat_yourName_color.R", r); g = prefs.getNumber("chat_yourName_color.G", g); b = prefs.getNumber("chat_yourName_color.B", b); chat_yourName_color.setRgb(r, g, b); r = config.readNumEntry("chat_buddyText_color.R", 0); g = config.readNumEntry("chat_buddyText_color.G", 0); b = config.readNumEntry("chat_buddyText_color.B", 0); r = prefs.getNumber("chat_buddyText_color.R", r); g = prefs.getNumber("chat_buddyText_color.G", g); b = prefs.getNumber("chat_buddyText_color.B", b); chat_contactText_color.setRgb(r, g, b); r = config.readNumEntry("chat_buddyName_color.R", 128); g = config.readNumEntry("chat_buddyName_color.G", 0); b = config.readNumEntry("chat_buddyName_color.B", 0); r = prefs.getNumber("chat_buddyName_color.R", r); g = prefs.getNumber("chat_buddyName_color.G", g); b = prefs.getNumber("chat_buddyName_color.B", b); chat_contactName_color.setRgb(r, g, b); r = config.readNumEntry("chat_buddyBg_color.R", 255); g = config.readNumEntry("chat_buddyBg_color.G", 255); b = config.readNumEntry("chat_buddyBg_color.B", 255); r = prefs.getNumber("chat_buddyBg_color.R", r); g = prefs.getNumber("chat_buddyBg_color.G", g); b = prefs.getNumber("chat_buddyBg_color.B", b); chat_contactbg_color.setRgb(r, g, b); r = config.readNumEntry("chat_yourBg_color.R", 255); g = config.readNumEntry("chat_yourBg_color.G", 255); b = config.readNumEntry("chat_yourBg_color.B", 255); r = prefs.getNumber("chat_yourBg_color.R", r); g = prefs.getNumber("chat_yourBg_color.G", g); b = prefs.getNumber("chat_yourBg_color.B", b); chat_yourbg_color.setRgb(r, g, b); config.writeEntry( "chat_yourText_color", chat_yourText_color ); config.writeEntry( "chat_yourName_color", chat_yourName_color ); config.writeEntry( "chat_contactText_color", chat_contactText_color ); config.writeEntry( "chat_contactName_color", chat_contactName_color ); config.writeEntry( "chat_yourbg_color", chat_yourbg_color ); config.writeEntry( "chat_contactbg_color", chat_contactbg_color ); QFont defaultFont = qApp->font(); i_currentSettings->buddylistFontSettings->buddylist_OnlineFont=prefs.getFont("buddylist_OnlineFont", defaultFont); i_currentSettings->buddylistFontSettings->buddylist_OfflineFont=prefs.getFont("buddylist_OfflineFont", defaultFont); i_currentSettings->buddylistFontSettings->buddylist_SignOnFont=prefs.getFont("buddylist_SignOnFont", defaultFont); //for chat_*Font, we need the default to be 12 points. defaultFont.setPointSize(12); // chatwindow updates! QFont chat_yourFont = config.readFontEntry( "chat_yourFont", &defaultFont ); QFont chat_contactFont = config.readFontEntry( "chat_contactFont", &defaultFont ); chat_yourFont=prefs.getFont("chat_yourFont", chat_yourFont); chat_contactFont=prefs.getFont("chat_buddyFont", chat_contactFont); config.writeEntry( "chat_yourFont", chat_yourFont ); config.writeEntry( "chat_contactFont", chat_contactFont ); bool chat_sound; // Done bool chat_sound_beepInitial; // Done bool chat_sound_beepReceive; // Done bool chat_sound_beepSend; // Done bool chat_sound_playFile; // Done QString chat_sound_fileSend; // Done QString chat_sound_fileReceive; // Done QString chat_sound_fileInitial; // Done chat_sound= config.readBoolEntry("chat_sound_enable", true); chat_sound_beepInitial= config.readBoolEntry("chat_sound_beepInitial", true); chat_sound_beepReceive= config.readBoolEntry("chat_sound_beepReceive", true); chat_sound_beepSend= config.readBoolEntry("chat_sound_beepSend", true); chat_sound_playFile = config.readBoolEntry("chat_sound_playFile", false); chat_sound_fileSend= config.readEntry("chat_sound_fileSend", DATADIR "/sounds/Send.au"); chat_sound_fileReceive= config.readEntry("chat_sound_fileReceive", DATADIR "/sounds/Receive.au"); chat_sound_fileInitial= config.readEntry("chat_sound_fileInitial", DATADIR "/sounds/Receive.au"); chat_sound= prefs.getBool("chat_sound_enable", chat_sound); chat_sound_beepInitial= prefs.getBool("chat_sound_beepInitial", chat_sound_beepInitial); chat_sound_beepReceive= prefs.getBool("chat_sound_beepReceive",chat_sound_beepReceive ); chat_sound_beepSend= prefs.getBool("chat_sound_beepSend", chat_sound_beepSend); chat_sound_playFile = prefs.getBool("chat_sound_playFile", chat_sound_playFile); chat_sound_fileSend= prefs.getString("chat_sound_fileSend", chat_sound_fileSend); chat_sound_fileReceive= prefs.getString("chat_sound_fileReceive", chat_sound_fileReceive); chat_sound_fileInitial= prefs.getString("chat_sound_fileInitial", chat_sound_fileInitial); config.writeEntry("chat_sound", chat_sound); config.writeEntry("chat_sound_beepInitial", chat_sound_beepInitial); config.writeEntry("chat_sound_beepReceive", chat_sound_beepReceive); config.writeEntry("chat_sound_beepSend", chat_sound_beepSend); config.writeEntry("chat_sound_playFile", chat_sound_playFile); config.writeEntry("chat_sound_fileSend", chat_sound_fileSend); config.writeEntry("chat_sound_fileReceive", chat_sound_fileReceive); config.writeEntry("chat_sound_fileInitial", chat_sound_fileInitial); i_currentSettings->IgnoreThisUpdate= prefs.getString("IgnoreThisUpdate", i_currentSettings->ReleaseDate); prefs.setGroup("away list"); i_currentSettings->mapAwayMessages->clear(); for(i = 1; i <= prefs.getNumber("away_message_count"); i++){ i_currentSettings->mapAwayMessages->insert( prefs.getString(QString("away_message_%1").arg(i)), prefs.getAttr1(QString("away_message_%1").arg(i)) ); } if (i_currentSettings->mapAwayMessages->count() == 0){ i_currentSettings->mapAwayMessages->insert("Default Away", "I am sorry, but I am away from the computer right now."); } }
const KstTimezones::ZoneMap KstTimezones::allZones() { // Have we already done all the hard work? If not, create the cache. if (m_zones) return *m_zones; m_zones = new ZoneMap(); // Go read the database. // // On Windows, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones // is the place to look. The TZI binary value is the TIME_ZONE_INFORMATION structure. // // For Unix its all easy except knowing where to look. Try the LSB location first. QFile f; m_zoneinfoDir = "/usr/share/zoneinfo"; f.setName(m_zoneinfoDir + "/zone.tab"); if (!f.open(IO_ReadOnly)) { m_zoneinfoDir = "/usr/lib/zoneinfo"; f.setName(m_zoneinfoDir + "/zone.tab"); if (!f.open(IO_ReadOnly)) { m_zoneinfoDir = ::getenv("TZDIR"); f.setName(m_zoneinfoDir + "/zone.tab"); if (m_zoneinfoDir.isEmpty() || !f.open(IO_ReadOnly)) { // Solaris support. Synthesise something that looks like a zone.tab. // // /bin/grep -h ^Zone /usr/share/lib/zoneinfo/src/* | /bin/awk '{print "??\t+9999+99999\t" $2}' // // where the country code is set to "??" and the lattitude/longitude // values are dummies. m_zoneinfoDir = "/usr/share/lib/zoneinfo"; KTempFile temp; KShellProcess reader; reader << "/bin/grep" << "-h" << "^Zone" << m_zoneinfoDir << "/src/*" << temp.name() << "|" << "/bin/awk" << "'{print \"??\\t+9999+99999\\t\" $2}'"; // Note the use of blocking here...it is a trivial amount of data! temp.close(); reader.start(KProcess::Block); f.setName(temp.name()); if (!temp.status() || !f.open(IO_ReadOnly)) { return *m_zones; } } } } // Parse the zone.tab. QTextStream str(&f); QRegExp lineSeparator("[ \t]"); QRegExp ordinateSeparator("[+-]"); KSharedPtr<KstTimezoneSource> db(new KstTimezoneSource(m_zoneinfoDir)); while (!str.atEnd()) { QString line = str.readLine(); if (line.isEmpty() || '#' == line[0]) continue; QStringList tokens = KStringHandler::perlSplit(lineSeparator, line, 4); if (tokens.count() < 3) { continue; } // Got three tokens. Now check for two ordinates plus first one is "". QStringList ordinates = KStringHandler::perlSplit(ordinateSeparator, tokens[1], 2); if (ordinates.count() < 2) { continue; } float latitude = convertCoordinate(ordinates[1]); float longitude = convertCoordinate(ordinates[2]); // Add entry to list. if (tokens[0] == "??") tokens[0] = ""; KstTimezone *timezone = new KstTimezone(db, tokens[2], tokens[0], latitude, longitude, tokens[3]); add(timezone); } f.close(); return *m_zones; }
void execute(const char* cmd){ KShellProcess proc; proc << cmd; proc.start(KShellProcess::DontCare); }