StylesConfig::StylesConfig(QWidget *parent, StylesPlugin *plugin) : QWidget( parent) { setupUi( this); m_plugin = plugin; for (QObject *p = parent; p != NULL; p = p->parent()) { if (!p->inherits("QTabWidget")) continue; QTabWidget *tab = static_cast<QTabWidget*>(p); font_cfg = new FontConfig(tab, m_plugin); tab->addTab(font_cfg, i18n("Fonts and colors")); break; } #if COMPAT_QT_VERSION >= 0x030000 lstStyle->insertStringList(QStyleFactory::keys()); #else for (const char **s = defStyles; *s; s++) lstStyle->insertItem(*s); #ifdef WIN32 QDir d(app_file("plugins\\styles\\").c_str()); QStringList styles = d.entryList("*.dll"); for (QStringList::Iterator it = styles.begin(); it != styles.end(); ++it) { QString name = *it; int n = name.findRev("."); if (n > 0) name = name.left(n); if (name == "xpstyle") { HINSTANCE hLib = LoadLibraryA("UxTheme.dll"); if (hLib == NULL) continue; FreeLibrary(hLib); } string dll = "plugins\\styles\\"; dll += name.toLatin1(); dll += ".dll"; HINSTANCE hLib = LoadLibraryA(app_file(dll.c_str()).c_str()); if (hLib == NULL) continue; StyleInfo* (*getStyleInfo)() = NULL; (DWORD&)getStyleInfo = (DWORD)GetProcAddress(hLib,"GetStyleInfo"); if (getStyleInfo) lstStyle->insertItem(name); FreeLibrary(hLib); } #endif #endif if (*m_plugin->getStyle()) { Q3ListBoxItem *item = lstStyle->findItem(m_plugin->getStyle()); if (item) lstStyle->setCurrentItem(item); } }
ConnectWnd::ConnectWnd() { setConnecting(true); #if QT_VERSION < 300 QMovie movie(QFile::decodeName(app_file("pict/connect.gif").c_str())); #else QMovie movie(QFile::decodeName(app_file("pict/connect.mng").c_str())); #endif lblMovie->setMovie(movie); movie.connectUpdate(this, SLOT(updateMovie())); setConnecting(true); movie.restart(); updateMovie(); }
void HistoryConfig::viewChanged(QWidget *w) { int cur = cmbStyle->currentItem(); if (cur < 0) return; if (w == preview){ if (!m_styles[cur].bCustom) return; if (m_bDirty){ m_styles[cur].text = unquoteText(edtStyle->text()); fillPreview(); } }else{ QString xsl; if (m_styles[cur].text.isEmpty()){ string name = STYLES; name += QFile::encodeName(m_styles[cur].name); name += EXT; name = m_styles[cur].bCustom ? user_file(name.c_str()) : app_file(name.c_str()); QFile f(QFile::decodeName(name.c_str())); if (f.open(IO_ReadOnly)){ name = ""; name.append(f.size(), '\x00'); f.readBlock((char*)(name.c_str()), f.size()); xsl = QString::fromUtf8(name.c_str()); }else{ log(L_WARN, "Can't open %s", name.c_str()); } }else{ xsl = m_styles[cur].text; } edtStyle->setText(quoteString(xsl)); QTimer::singleShot(0, this, SLOT(sync())); } }
string SoundPlugin::fullName(const char *name) { string sound; if ((name == NULL) || (*name == 0)) return sound; #ifdef WIN32 char c = name[0]; if (((((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'))) && (name[1] == ':')) || ((c == '\\') && (name[1] == '\\'))){ #else if (name[0] == '/'){ #endif sound = name; }else{ sound = "sounds/"; sound += name; sound = app_file(sound.c_str()); } return sound; } void SoundPlugin::playSound(const char *s) { if ((s == NULL) || (*s == 0)) return; string sound = fullName(s); #ifdef WIN32 sndPlaySoundA(sound.c_str(), SND_ASYNC | SND_NODEFAULT); #else #ifdef USE_KDE if (getUseArts()){ KAudioPlayer::play(sound.c_str()); return; } #endif ExecParam p; p.cmd = getPlayer(); p.arg = sound.c_str(); Event e(EventExec, &p); e.process(); #endif } #ifdef WIN32 /** * DLL's entry point **/ int WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) { return TRUE; } /** * This is to prevent the CRT from loading, thus making this a smaller * and faster dll. **/ extern "C" BOOL __stdcall _DllMainCRTStartup( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { return DllMain( hinstDLL, fdwReason, lpvReserved ); }
PluginManagerPrivate::PluginManagerPrivate(int argc, char **argv) : EventReceiver(LowPriority) { m_argc = argc; m_argv = argv; app_name = *argv; for (argv++, argc--; argc > 0; argv++, argc--){ args.push_back(string(*argv)); } m_base = 0; m_bLoaded = false; m_bInInit = true; QStringList pluginsList; QDir pluginDir(app_file("plugins").c_str()); #ifdef WIN32 pluginsList = pluginDir.entryList("*.dll"); #else pluginsList = pluginDir.entryList("*.so"); #endif m_bAbort = false; for (QStringList::Iterator it = pluginsList.begin(); it != pluginsList.end(); ++it){ QString f = *it; int p = f.findRev('.'); if (p > 0) f = f.left(p); pluginInfo info; info.plugin = NULL; #ifdef WIN32 info.name = strdup(QFile::encodeName(f.lower())); #else info.name = strdup(QFile::encodeName(f)); #endif info.config = NULL; info.bDisabled = false; info.bNoCreate = false; info.bFromCfg = false; info.module = NULL; info.info = NULL; info.base = 0; plugins.push_back(info); } sort(plugins.begin(), plugins.end(), cmp_plugin); for (vector<pluginInfo>::iterator itp = plugins.begin(); itp != plugins.end(); ++itp){ create((*itp)); if (m_bAbort) return; } m_bInInit = false; Event eStart(EventInit); eStart.process(); for (list<string>::iterator it_args = args.begin(); it_args != args.end(); ++it_args){ if ((*it_args).length()){ usage((*it_args).c_str()); break; } } }
HistoryConfig::HistoryConfig(QWidget *parent) : HistoryConfigBase(parent) { chkOwn->setChecked(CorePlugin::m_plugin->getOwnColors()); chkSmile->setChecked(CorePlugin::m_plugin->getUseSmiles()); cmbPage->setEditable(true); cmbPage->insertItem("100"); cmbPage->insertItem("50"); cmbPage->insertItem("25"); m_cur = -1; QLineEdit *edit = cmbPage->lineEdit(); edit->setValidator(new QIntValidator(1, 500, edit)); edit->setText(QString::number(CorePlugin::m_plugin->getHistoryPage())); QString str1 = i18n("Show %1 messages per page"); QString str2; int n = str1.find("%1"); if (n >= 0){ str2 = str1.mid(n + 2); str1 = str1.left(n); } lblPage1->setText(str1); lblPage2->setText(str2); edtStyle->setWordWrap(QTextEdit::NoWrap); edtStyle->setTextFormat(QTextEdit::RichText); #if (QT_VERSION < 0x300) || ((QT_VERSION >= 0x300) && defined(HAVE_QSYNTAXHIGHLIGHTER_H)) new XmlHighlighter(edtStyle); #endif QStringList styles; addStyles(user_file(STYLES).c_str(), true); #ifdef USE_KDE QStringList lst = KGlobal::dirs()->findDirs("data", "sim"); for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it){ QFile fi(*it + STYLES); if (!fi.exists()) continue; addStyles(QFile::encodeName(fi.name()), false); } #else addStyles(app_file(STYLES).c_str(), false); #endif fillCombo(CorePlugin::m_plugin->getHistoryStyle()); connect(cmbStyle, SIGNAL(activated(int)), this, SLOT(styleSelected(int))); connect(btnCopy, SIGNAL(clicked()), this, SLOT(copy())); connect(btnRename, SIGNAL(clicked()), this, SLOT(rename())); connect(btnDelete, SIGNAL(clicked()), this, SLOT(del())); connect(tabStyle, SIGNAL(currentChanged(QWidget*)), this, SLOT(viewChanged(QWidget*))); connect(edtStyle, SIGNAL(textChanged()), this, SLOT(textChanged())); connect(chkOwn, SIGNAL(toggled(bool)), this, SLOT(toggled(bool))); connect(chkSmile, SIGNAL(toggled(bool)), this, SLOT(toggled(bool))); connect(chkDays, SIGNAL(toggled(bool)), this, SLOT(toggledDays(bool))); connect(chkSize, SIGNAL(toggled(bool)), this, SLOT(toggledSize(bool))); HistoryUserData *data = (HistoryUserData*)(getContacts()->getUserData(CorePlugin::m_plugin->history_data_id)); chkDays->setChecked(data->CutDays.bValue); chkSize->setChecked(data->CutSize.bValue); edtDays->setValue(data->Days.value); edtSize->setValue(data->MaxSize.value); toggledDays(chkDays->isChecked()); toggledSize(chkSize->isChecked()); }
void StylesPlugin::setStyles() { QStyle *style = NULL; #if QT_VERSION >= 300 if (*getStyle()) style = QStyleFactory::create(getStyle()); #else if (*getStyle()){ string s = getStyle(); if (s == "windows"){ style = new QWindowsStyle; }else if (s == "motif"){ style = new QMotifStyle; }else if (s == "cde"){ style = new QCDEStyle; }else if (s == "motifplus"){ style = new QMotifPlusStyle; }else if (s == "platinum"){ style = new QPlatinumStyle; }else if (s == "sgi"){ style = new QSGIStyle; #ifdef WIN32 }else{ bool bOK = true; if (s == "xpstyle"){ HINSTANCE hLib = LoadLibraryA("UxTheme.dll"); if (hLib){ FreeLibrary(hLib); }else{ bOK = false; } } if (bOK){ string dll = "plugins\\styles\\"; dll += s; dll += ".dll"; HINSTANCE hLib = LoadLibraryA(app_file(dll.c_str()).c_str()); if (hLib){ StyleInfo* (*getStyleInfo)() = NULL; (DWORD&)getStyleInfo = (DWORD)GetProcAddress(hLib,"GetStyleInfo"); if (getStyleInfo){ StyleInfo *info = getStyleInfo(); if (info && info->create) style = info->create(); } } } #endif } } #endif if (style){ QApplication::setStyle(style); if (!getSystemColors()) setColors(); }else{ setStyle(NULL); } }
void IconCfg::add() { #ifdef USE_KDE QString filter = i18n("*.jisp|Icon set"); #else QString filter = i18n("Icon set(*.jisp)"); #endif QString jisp = QFile::decodeName(QFileDialog::getOpenFileName(QFile::decodeName(app_file("icons/").c_str()), filter, topLevelWidget(), i18n("Select icon set")).local8Bit()); if (!jisp.isEmpty()) lstIcon->insertItem(jisp); }
// static void LLSpellChecker::refreshDictionaryMap() { const std::string app_path = getDictionaryAppPath(); const std::string user_path = getDictionaryUserPath(); // Load dictionary information (file name, friendly name, ...) std::string user_filename(user_path + DICT_FILE_MAIN); llifstream user_file(user_filename.c_str(), std::ios::binary); if ( (!user_file.is_open()) || (LLSDParser::PARSE_FAILURE == LLSDSerialize::fromXMLDocument(sDictMap, user_file)) || (0 == sDictMap.size()) ) { std::string app_filename(app_path + DICT_FILE_MAIN); llifstream app_file(app_filename.c_str(), std::ios::binary); if ( (!app_file.is_open()) || (LLSDParser::PARSE_FAILURE == LLSDSerialize::fromXMLDocument(sDictMap, app_file)) || (0 == sDictMap.size()) ) { return; } } // Load user installed dictionary information llifstream custom_file(user_filename.c_str(), std::ios::binary); if (custom_file.is_open()) { LLSD custom_dict_map; LLSDSerialize::fromXMLDocument(custom_dict_map, custom_file); for (LLSD::array_iterator it = custom_dict_map.beginArray(); it != custom_dict_map.endArray(); ++it) { LLSD& dict_info = *it; dict_info["user_installed"] = true; setDictionaryData(dict_info); } custom_file.close(); } // Look for installed dictionaries std::string tmp_app_path, tmp_user_path; for (LLSD::array_iterator it = sDictMap.beginArray(); it != sDictMap.endArray(); ++it) { LLSD& sdDict = *it; tmp_app_path = (sdDict.has("name")) ? app_path + sdDict["name"].asString() : LLStringUtil::null; tmp_user_path = (sdDict.has("name")) ? user_path + sdDict["name"].asString() : LLStringUtil::null; sdDict["installed"] = (!tmp_app_path.empty()) && ((gDirUtilp->fileExists(tmp_user_path + ".dic")) || (gDirUtilp->fileExists(tmp_app_path + ".dic"))); } sSettingsChangeSignal(); }
EditSound::EditSound(QWidget *p, const char *name) : EditFile(p, name) { QPushButton *btnPlay = new QPushButton(this); lay->addSpacing(3); lay->addWidget(btnPlay); btnPlay->setPixmap(Pict("1rightarrow")); connect(btnPlay, SIGNAL(clicked()), this, SLOT(play())); #ifdef USE_KDE filter = i18n("*.wav|Sounds"); #else filter = i18n("Sounds(*.wav)"); #endif startDir = QFile::decodeName(app_file("sound").c_str()); title = i18n("Select sound"); }
HistoryConfig::HistoryConfig(QWidget *parent) : HistoryConfigBase(parent) { chkOwn->setChecked(CorePlugin::m_plugin->getOwnColors()); chkSmile->setChecked(CorePlugin::m_plugin->getUseSmiles()); cmbPage->setEditable(true); cmbPage->insertItem("100"); cmbPage->insertItem("50"); cmbPage->insertItem("25"); m_cur = -1; QLineEdit *edit = cmbPage->lineEdit(); edit->setValidator(new QIntValidator(1, 500, edit)); edit->setText(QString::number(CorePlugin::m_plugin->getHistoryPage())); QString str1 = i18n("Show %1 messages per page"); QString str2; int n = str1.find("%1"); if (n >= 0){ str2 = str1.mid(n + 2); str1 = str1.left(n); } lblPage1->setText(str1); lblPage2->setText(str2); edtStyle->setWordWrap(QTextEdit::NoWrap); edtStyle->setTextFormat(QTextEdit::RichText); new XmlHighlighter(edtStyle); QStringList styles; addStyles(user_file(STYLES).c_str(), true); addStyles(app_file(STYLES).c_str(), false); fillCombo(CorePlugin::m_plugin->getHistoryStyle()); connect(cmbStyle, SIGNAL(activated(int)), this, SLOT(styleSelected(int))); connect(btnCopy, SIGNAL(clicked()), this, SLOT(copy())); connect(btnRename, SIGNAL(clicked()), this, SLOT(rename())); connect(btnDelete, SIGNAL(clicked()), this, SLOT(del())); connect(tabStyle, SIGNAL(currentChanged(QWidget*)), this, SLOT(viewChanged(QWidget*))); connect(edtStyle, SIGNAL(textChanged()), this, SLOT(textChanged())); connect(chkOwn, SIGNAL(toggled(bool)), this, SLOT(toggled(bool))); connect(chkSmile, SIGNAL(toggled(bool)), this, SLOT(toggled(bool))); connect(chkDays, SIGNAL(toggled(bool)), this, SLOT(toggledDays(bool))); connect(chkSize, SIGNAL(toggled(bool)), this, SLOT(toggledSize(bool))); HistoryUserData *data = (HistoryUserData*)(getContacts()->getUserData(CorePlugin::m_plugin->history_data_id)); chkDays->setChecked(data->CutDays != 0); chkSize->setChecked(data->CutSize != 0); edtDays->setValue(data->Days); edtSize->setValue(data->MaxSize); toggledDays(chkDays->isChecked()); toggledSize(chkSize->isChecked()); }
SmileCfg::SmileCfg(QWidget *parent, IconsPlugin *plugin) : SmileCfgBase(parent) { m_plugin = plugin; lblMore->setUrl("http://miranda-im.org/download/index.php?action=display&id=41"); #ifdef WIN32 edtSmiles->setStartDir(QFile::decodeName(app_file("smiles/").c_str())); #else edtSmiles->setStartDir(QFile::decodeName(user_file("smiles/").c_str())); #endif edtSmiles->setTitle(i18n("Select smiles")); edtSmiles->setFilePreview(createPreview); #ifdef USE_KDE edtSmiles->setFilter(i18n("*.msl *.xep|Smiles")); #else edtSmiles->setFilter(i18n("Smiles (*.msl *.xep)")); #endif edtSmiles->setText(m_plugin->getSmiles()); lblMore->setText(i18n("Get more smiles")); }
string HomeDirPlugin::defaultPath() { string s; #ifndef WIN32 struct passwd *pwd = getpwuid(getuid()); if (pwd){ s = pwd->pw_dir; }else{ log(L_ERROR, "Can't get pwd"); } if (s[s.size() - 1] != '/') s += '/'; #ifdef USE_KDE char *kdehome = getenv("KDEHOME"); if (kdehome){ s = kdehome; }else{ s += ".kde/"; } if (s.length() == 0) s += '/'; if (s[s.length()-1] != '/') s += '/'; s += "share/apps/sim"; #else s += ".sim"; #endif #else char szPath[512]; HINSTANCE hLib = LoadLibraryA("Shell32.dll"); if (hLib != NULL) (DWORD&)_SHGetSpecialFolderPath = (DWORD)GetProcAddress(hLib,"SHGetSpecialFolderPathA"); if (_SHGetSpecialFolderPath && _SHGetSpecialFolderPath(NULL, szPath, CSIDL_APPDATA, true)){ s = szPath; if (s.length() == 0) s = "c:\\"; if (s[s.length() - 1] != '\\') s += '\\'; s += "sim"; }else{ s = app_file(""); } #endif return s; }
SplashPlugin::SplashPlugin(unsigned base, bool bStart) : Plugin(base), EventReceiver(LowestPriority) { splash = NULL; m_bStart = bStart; if (m_bStart){ string pictPath = app_file("pict/splash.png"); QPixmap pict(QFile::decodeName(pictPath.c_str())); if (!pict.isNull()){ splash = new QWidget(NULL, "splash", QWidget::WType_TopLevel | QWidget::WStyle_Customize | QWidget::WStyle_NoBorderEx | QWidget::WStyle_StaysOnTop); splash->resize(pict.width(), pict.height()); QWidget *desktop = QApplication::desktop(); splash->move((desktop->width() - pict.width()) / 2, (desktop->height() - pict.height()) / 2); splash->setBackgroundPixmap(pict); const QBitmap *mask = pict.mask(); if (mask) splash->setMask(*mask); splash->show(); } } }
XSL::XSL(const QString &name) { string fname = STYLES; fname += static_cast<string>(QFile::encodeName(name)); fname += EXT; QFile f(QFile::decodeName(user_file(fname.c_str()).c_str())); bool bOK = true; if (!f.open(QIODevice::ReadOnly)){ f.setFileName(QFile::decodeName(app_file(fname.c_str()).c_str())); if (!f.open(QIODevice::ReadOnly)){ log(L_WARN, "Can't open %s", fname.c_str()); bOK = false; } } string xsl; if (bOK){ xsl.append(f.size(), '\x00'); f.read((char*)(xsl.c_str()), f.size()); f.close(); } d = new XSLPrivate(xsl.c_str()); }
BkgndCfg::BkgndCfg(QWidget *parent, BackgroundPlugin *plugin) : BkgndCfgBase(parent) { m_plugin = plugin; edtPicture->setText(QFile::decodeName(plugin->getBackground())); edtPicture->setStartDir(QFile::decodeName(app_file("pict/").c_str())); edtPicture->setTitle(i18n("Select background picture")); QStrList formats = QImageIO::inputFormats(); QString format; QStrListIterator it(formats); char *fmt; while ((fmt = ++it) != NULL){ if (format.length()) format += " "; QString f = fmt; f = f.lower(); format += "*." + f; if (f == "jpeg") format += " *.jpg"; } #ifdef USE_KDE edtPicture->setFilter(i18n("%1|Graphics") .arg(format)); #else edtPicture->setFilter(i18n("Graphics(%1)") .arg(format)); edtPicture->setFilePreview(createPreview); #endif cmbPosition->insertItem(i18n("Contact - left")); cmbPosition->insertItem(i18n("Contact - scale")); cmbPosition->insertItem(i18n("Window - left top")); cmbPosition->insertItem(i18n("Window - left bottom")); cmbPosition->insertItem(i18n("Window - left center")); cmbPosition->insertItem(i18n("Window - scale")); cmbPosition->setCurrentItem(plugin->getPosition()); spnMargin->setMaxValue(20); spnMargin->setValue(plugin->getMargin()); lblLink->setText(i18n("Get more skins")); lblLink->setUrl("http://miranda-im.org/download/index.php?action=display&id=32"); }
int main(int argc, char *argv[]) { int res = 1; #ifdef WIN32 HANDLE hMutex = CreateMutexA(NULL, FALSE, "SIM_Mutex"); #endif QApplication::setColorSpec( QApplication::ManyColor ); #ifndef WIN32 qInstallMsgHandler(simMessageOutput); #endif KAboutData aboutData(PACKAGE, I18N_NOOP("SIM"), _VERSION, I18N_NOOP("ICQ client"), KAboutData::License_GPL, "Copyright (C) 2002-2003, Vladimir Shutoff", 0, "http://sim-icq.sourceforge.net/", "*****@*****.**"); aboutData.addAuthor("Vladimir Shutoff",I18N_NOOP("Maintainer"),"*****@*****.**"); aboutData.addAuthor("Christian Ehrlicher",I18N_NOOP("Developer"),"*****@*****.**"); setAboutData(&aboutData); #ifndef WIN32 int _argc = 0; char **_argv = new char*[argc + 1]; _argv[_argc++] = argv[0]; char **to = argv + 1; // check all parameters and sort them // _argc/v: parameter for KUnqiueApplication // argc/v: plugin parameter for (char **p = argv + 1; *p; ++p){ char *arg = *p; // check if "-" or "--" if (arg[0] != '-') { // wrong parameter :( argc--; continue; } arg++; if (arg[0] == '-') arg++; // if they are parameters with variable params we need // to skip the next param bool bSkip = false; const char **q; // check for qt or kde - parameters for (q = qt_args; *q; ++q){ unsigned len = strlen(*q); bSkip = false; // variable parameter? if ((*q)[len-1] == ':'){ len--; bSkip = true; } // copy them for KUnqiueApplication-args if ((strlen(arg) == len) && !memcmp(arg, *q, len)) break; } // dunno know what to do here if (*q){ _argv[_argc++] = *p; argc--; if (bSkip){ ++p; if (*p == NULL) break; _argv[_argc++] = *p; argc--; } }else{ *(to++) = *p; } } *to = NULL; _argv[_argc] = NULL; #ifdef USE_KDE KCmdLineArgs::init( _argc, _argv, &aboutData ); KCmdLineOptions options[] = { { 0, 0, 0 } }; KCmdLineArgs::addCmdLineOptions( options ); KUniqueApplication::addCmdLineOptions(); if (!KUniqueApplication::start()) exit(-1); SimApp app; #else SimApp app(_argc, _argv); #endif old_errhandler = XSetErrorHandler(x_errhandler); #else SimApp app(argc, argv); QStyle* (WINAPI *createXpStyle)() = NULL; HINSTANCE hLib = LoadLibraryA("UxTheme.dll"); if (hLib != NULL) hLib = LoadLibraryA(app_file("plugins\\styles\\xpstyle.dll").c_str()); if (hLib != NULL) (DWORD&)createXpStyle = (DWORD)GetProcAddress(hLib,"_createXpStyle@0"); if (createXpStyle){ QStyle *xpStyle = createXpStyle(); qApp->setStyle(xpStyle); } #endif PluginManager p(argc, argv); if (p.isLoaded()) res = app.exec(); #ifdef WIN32 CloseHandle(hMutex); #endif return res; };
IconCfg::IconCfg(QWidget *parent, IconsPlugin *plugin) : IconCfgBase(parent) { m_plugin = plugin; unsigned i; for (i = 1; ; i++){ const char *n = plugin->getIconDLLs(i); if ((n == NULL) || (*n == 0)) break; string v = n; IconsDef d; d.protocol = getToken(v, ','); d.icon = v; d.index = -1; defs.push_back(d); } list<string> icons; Event e(EventGetIcons, &icons); e.process(); list<string> protocols; for (list<string>::iterator it = icons.begin(); it != icons.end(); ++it){ string name = (*it); int n = name.find('_'); char c = name[0]; if ((c < 'A') || (c > 'Z')) continue; if (n <= 0) continue; name = name.substr(0, n); list<string>::iterator its; for (its = protocols.begin(); its != protocols.end(); ++its) if ((*its) == name) break; if (its != protocols.end()) continue; protocols.push_back(name); } i = 0; for (list<string>::iterator its = protocols.begin(); its != protocols.end(); ++its, i++){ cmbProtocol->insertItem(i18n((*its).c_str())); list<IconsDef>::iterator it; for (it = defs.begin(); it != defs.end(); ++it){ if ((*it).protocol == (*its)){ (*it).index = i; break; } } if (it == defs.end()){ IconsDef d; d.protocol = (*its); d.index = i; defs.push_back(d); } } connect(cmbProtocol, SIGNAL(activated(int)), this, SLOT(protocolChanged(int))); cmbProtocol->setCurrentItem(0); protocolChanged(0); lblMore->setUrl("http://miranda-im.org/download/index.php?action=display&id=35"); #ifdef WIN32 edtIcon->setStartDir(QFile::decodeName(app_file("icons/").c_str())); #else edtIcon->setStartDir(QFile::decodeName(user_file("icons/").c_str())); #endif edtIcon->setTitle(i18n("Select icons DLL")); edtIcon->setFilePreview(createPreview); #ifdef USE_KDE edtIcon->setFilter(i18n("*.dll|Icons themes")); #else edtIcon->setFilter(i18n("Icons themes (*.dll)")); #endif lblMore->setText(i18n("Get more icons themes")); connect(edtIcon, SIGNAL(textChanged(const QString&)), this, SLOT(textChanged(const QString&))); for (QObject *p = parent; p != NULL; p = p->parent()){ if (!p->inherits("QTabWidget")) continue; QTabWidget *tab = static_cast<QTabWidget*>(p); m_smiles = new SmileCfg(tab, plugin); tab->addTab(m_smiles, i18n("Smiles")); tab->adjustSize(); break; } }
string SoundPlugin::fullName(const char *name) { string sound; if ((name == NULL) || (*name == 0)) return sound; #ifdef WIN32 char c = name[0]; if (((((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'))) && (name[1] == ':')) || ((c == '\\') && (name[1] == '\\'))){ #else if (name[0] == '/'){ #endif sound = name; }else{ sound = "sounds/"; sound += name; sound = app_file(sound.c_str()); } return sound; } void SoundPlugin::playSound(const char *s) { if ((s == NULL) || (*s == 0)) return; string sound = fullName(s); // check whether file is available if (!QFile::exists(QString(sound.c_str()))) return; bool bSound = QSound::available(); #ifdef USE_KDE if (getUseArts()){ KAudioPlayer::play(sound.c_str()); return; } bSound = false; #endif if (bSound){ QSound s(sound.c_str()); s.play(); return; } ExecParam p; p.cmd = getPlayer(); if (*p.cmd == 0) return; p.arg = sound.c_str(); Event e(EventExec, &p); e.process(); } #ifdef WIN32 #include <windows.h> /** * DLL's entry point **/ int WINAPI DllMain(HINSTANCE, DWORD, LPVOID) { return TRUE; } /** * This is to prevent the CRT from loading, thus making this a smaller * and faster dll. **/ extern "C" BOOL __stdcall _DllMainCRTStartup( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { return DllMain( hinstDLL, fdwReason, lpvReserved ); }
KAboutApplication::KAboutApplication( const KAboutData *aboutData, QWidget *parent, const char *name, bool modal) : AboutDlgBase(parent, name, modal) { SET_WNDPROC("about") setButtonsPict(this); setCaption(caption()); connect(btnOK, SIGNAL(clicked()), this, SLOT(close())); setIcon(Pict("licq")); const QIconSet *icon = Icon("licq"); if (icon) lblIcon->setPixmap(icon->pixmap(QIconSet::Large, QIconSet::Normal)); lblVersion->setText(i18n("%1 Version: %2") .arg(aboutData->appName()) .arg(aboutData->version())); txtAbout->setText((QString("<center><br>%1<br><br>%2<br><br>") + "<a href=\"%3\">%4</a><br><br>" + i18n("Bug report") + ": <a href=\"mailto:%5\">%6</a><br>" + i18n("Note: This is english mailing list") + "</center>") .arg(quote(aboutData->shortDescription())) .arg(quote(aboutData->copyrightStatement())) .arg(quote(aboutData->homepage())) .arg(quote(aboutData->homepage())) .arg(quote(aboutData->bugAddress())) .arg(quote(aboutData->bugAddress()))); QString txt; QValueList<KAboutPerson>::ConstIterator it; for (it = aboutData->authors().begin(); it != aboutData->authors().end(); ++it) { txt += addPerson(&(*it)); txt += "<br>"; } txtAuthors->setText(txt); txt = ""; QValueList<KAboutTranslator> translators = aboutData->translators(); QValueList<KAboutTranslator>::ConstIterator itt; if (!translators.isEmpty()){ for (itt = translators.begin(); itt != translators.end(); ++itt) { const KAboutTranslator &t = *itt; txt += QString("%1 <<a href=\"mailto:%2\">%3</a>><br>") .arg(quote(t.name())) .arg(quote(t.emailAddress())) .arg(quote(t.emailAddress())); txt += "<br>"; } txtTranslations->setText(txt); }else{ tabMain->removePage(tabTranslation); } QString license = aboutData->license(); license += "\n\n"; QFile f(QFile::decodeName(app_file("COPYING").c_str())); if (f.open(IO_ReadOnly)){ for (;;){ QString s; if (f.readLine(s, 512) == -1) break; license += s; } } txtLicence->setText(quote(license)); }
int main(int argc, char *argv[]) { int res = 1; #ifdef WIN32 Qt::HANDLE hMutex = CreateMutexA(NULL, FALSE, "SIM_Mutex"); #endif QApplication::setColorSpec( QApplication::ManyColor ); Q_INIT_RESOURCE(sim); qInstallMsgHandler(simMessageOutput); KAboutData aboutData(PACKAGE, I18N_NOOP("SIM"), _VERSION, I18N_NOOP("Multiprotocol Instant Messenger"), KAboutData::License_GPL, "Copyright (C) 2002-2004, Vladimir Shutoff", 0, "http://sim-im.berlios.de/", "https://lists.berlios.de/mailman/listinfo/sim-im-main"); aboutData.addAuthor("Vladimir Shutoff",I18N_NOOP("Maintainer"),"*****@*****.**"); aboutData.addAuthor("Christian Ehrlicher",I18N_NOOP("Developer"),"*****@*****.**"); aboutData.addAuthor("Albert Valiev",I18N_NOOP("Current maintainer"),"*****@*****.**"); setAboutData(&aboutData); #ifndef WIN32 int _argc = 0; char **_argv = new char*[argc + 1]; _argv[_argc++] = argv[0]; char **to = argv + 1; // check all parameters and sort them // _argc/v: parameter for KUnqiueApplication // argc/v: plugin parameter for (char **p = argv + 1; *p; ++p){ char *arg = *p; // check if "-" or "--" if (arg[0] != '-') { *(to++) = *p; continue; } arg++; if (arg[0] == '-') arg++; // if they are parameters with variable params we need // to skip the next param bool bSkip = false; const char **q; // check for qt or kde - parameters for (q = qt_args; *q; ++q){ unsigned len = strlen(*q); bSkip = false; // variable parameter? if ((*q)[len-1] == ':'){ len--; bSkip = true; } // copy them for KUnqiueApplication-args if ((strlen(arg) == len) && !memcmp(arg, *q, len)) break; } // dunno know what to do here if (*q){ _argv[_argc++] = *p; argc--; if (bSkip){ ++p; if (*p == NULL) break; _argv[_argc++] = *p; argc--; } }else{ *(to++) = *p; } } *to = NULL; _argv[_argc] = NULL; #ifdef USE_KDE KCmdLineArgs::init( _argc, _argv, &aboutData ); KCmdLineOptions options[] = { { 0, 0, 0 } }; KCmdLineArgs::addCmdLineOptions( options ); KUniqueApplication::addCmdLineOptions(); if (!KUniqueApplication::start()) exit(-1); SimApp app; #else SimApp app(_argc, _argv); #endif #if !defined(QT_MACOSX_VERSION) && !defined(QT_MAC) old_errhandler = XSetErrorHandler(x_errhandler); #endif #else for (int i = 0; i < argc; i++){ string arg = argv[i]; if ((arg[0] == '/') || (arg[0] == '-')) arg = arg.substr(1); if ((arg == "reinstall") || (arg == "showicons") || (arg == "hideicons")) return 0; } SimApp app(argc, argv); StyleInfo* (*getStyleInfo)() = NULL; HINSTANCE hLib = LoadLibraryA("UxTheme.dll"); if (hLib != NULL) hLib = LoadLibraryA(app_file("plugins\\styles\\xpstyle.dll").c_str()); if (hLib != NULL) (DWORD&)getStyleInfo = (DWORD)GetProcAddress(hLib,"GetStyleInfo"); if (getStyleInfo){ StyleInfo *info = getStyleInfo(); if (info) qApp->setStyle(info->create()); } #endif PluginManager p(argc, argv); if (p.isLoaded()) res = app.exec(); #ifdef WIN32 CloseHandle(hMutex); #endif return 0; }
string HomeDirPlugin::defaultPath() { string s; #ifndef WIN32 struct passwd *pwd = getpwuid(getuid()); if (pwd){ s = pwd->pw_dir; }else{ log(L_ERROR, "Can't get pwd"); } if (s[s.size() - 1] != '/') s += '/'; #ifdef USE_KDE char *kdehome = getenv("KDEHOME"); if (kdehome){ s = kdehome; }else{ s += ".kde/"; } if (s.length() == 0) s += '/'; if (s[s.length()-1] != '/') s += '/'; s += "share/apps/sim"; #else s += ".sim"; #endif #else char szPath[1024]; szPath[0] = 0; HINSTANCE hLib = LoadLibraryA("Shell32.dll"); QString defPath; if (hLib != NULL){ (DWORD&)_SHGetSpecialFolderPathW = (DWORD)GetProcAddress(hLib,"SHGetSpecialFolderPathW"); (DWORD&)_SHGetSpecialFolderPathA = (DWORD)GetProcAddress(hLib,"SHGetSpecialFolderPathA"); } if (_SHGetSpecialFolderPathW && _SHGetSpecialFolderPathW(NULL, szPath, CSIDL_APPDATA, true)){ for (unsigned short *str = (unsigned short*)szPath; *str; str++) defPath += QChar(*str); }else if (_SHGetSpecialFolderPathA && _SHGetSpecialFolderPathA(NULL, szPath, CSIDL_APPDATA, true)){ defPath = QFile::decodeName(szPath); } if (!defPath.isEmpty()){ if (defPath[(int)(defPath.length() - 1)] != '\\') defPath += "\\"; defPath += "sim"; string ss; ss = QFile::encodeName(defPath); ss += "\\"; makedir((char*)(ss.c_str())); QString lockTest = defPath + "\\.lock"; QFile f(lockTest); if (!f.open(IO_ReadWrite | IO_Truncate)) defPath = ""; f.close(); QFile::remove(lockTest); } if (!defPath.isEmpty()){ s = QFile::encodeName(defPath); }else{ s = app_file(""); } #endif #ifdef HAVE_CHMOD chmod(s.c_str(), 0700); #endif return s; }
string SoundPlugin::fullName(const char *name) { string sound=""; string str_name = name; if ((name == NULL) || (*name == 0) || (str_name == "(nosound)")) return sound; #ifdef WIN32 char c = name[0]; if (((((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'))) && (name[1] == ':')) || ((c == '\\') && (name[1] == '\\'))){ #else if (name[0] == '/'){ #endif sound = name; }else{ sound = "sounds/"; sound += name; sound = app_file(sound.c_str()); } return sound; } void SoundPlugin::playSound(const char *s) { if ((s == NULL) || (*s == 0)) return; if (m_current == s) return; for (list<string>::iterator it = m_queue.begin(); it != m_queue.end(); ++it){ if ((*it) == s) return; } m_queue.push_back(s); if (m_sound == NULL) processQueue(); } void SoundPlugin::processQueue() { if (!m_current.empty() || m_queue.empty()) return; m_current = m_queue.front(); m_queue.erase(m_queue.begin()); string sound = fullName(m_current.c_str()); // check whether file is available if (!QFile::exists(QString(sound.c_str()))) { m_current=""; return; } #ifdef USE_KDE if (getUseArts()){ KAudioPlayer::play(sound.c_str()); m_checkTimer->start(WAIT_SOUND_TIMEOUT); m_current = ""; return; // arts } bool bSound = false; #elif WIN32 bool bSound = true; #else /* If there is an external player selected, don't use Qt Check first for getPlayer() since QSound::available() can take 5 seconds to return a value */ bool bSound = !getPlayer() && QSound::available(); #endif if (bSound){ if (!QSound::available()){ m_queue.clear(); m_current = ""; return; } if (m_sound) delete m_sound; m_sound = NULL; m_sound = new QSound(sound.c_str()); m_sound->play(); #if COMPAT_QT_VERSION >= 0x030000 m_checkTimer->start(CHECK_SOUND_TIMEOUT); #else m_checkTimer->start(WAIT_SOUND_TIMEOUT); #endif m_current = ""; return; // QSound } #ifndef WIN32 ExecParam p; p.cmd = getPlayer(); if (*p.cmd == 0) { m_current=""; return; } p.arg = sound.c_str(); Event e(EventExec, &p); m_player = (int)e.process(); if (m_player == 0){ log(L_WARN, "Can't execute player"); m_queue.clear(); } m_current = ""; return; // external Player #endif } void SoundPlugin::checkSound() { bool bDone = true; #if COMPAT_QT_VERSION >= 0x030000 if (m_sound && !m_sound->isFinished()) bDone = false; #endif if (bDone){ m_checkTimer->stop(); if (m_sound) delete m_sound; m_sound = NULL; m_current = ""; processQueue(); } }
void HistoryConfig::copy() { int cur = cmbStyle->currentItem(); if (cur < 0) return; QString name = m_styles[cur].name; QString newName; QRegExp re("\\.[0-9]+$"); unsigned next = 0; for (vector<StyleDef>::iterator it = m_styles.begin(); it != m_styles.end(); ++it){ QString nn = (*it).name; int n = nn.find(re); if (n < 0) continue; nn = nn.mid(n + 1); next = QMAX(next, nn.toUInt()); } int nn = name.find(re); if (nn >= 0){ newName = name.left(nn); }else{ newName = name; } newName += "."; newName += QString::number(next + 1); string n; n = STYLES; n += QFile::encodeName(name); n += EXT; if (m_styles[cur].bCustom){ n = user_file(n.c_str()); }else{ n = app_file(n.c_str()); } QFile from(QFile::decodeName(n.c_str())); if (!from.open(IO_ReadOnly)){ log(L_WARN, "Can't open %s", n.c_str()); return; } n = STYLES; n += QFile::encodeName(newName); n += EXT; n = user_file(n.c_str()); QFile to(QFile::decodeName(n.c_str())); if (!to.open(IO_WriteOnly | IO_Truncate)){ log(L_WARN, "Cam't create %s", n.c_str()); return; } string s; s.append(from.size(), '\x00'); from.readBlock((char*)(s.c_str()), from.size()); to.writeBlock(s.c_str(), s.length()); from.close(); to.close(); s = ""; StyleDef d; d.name = newName; d.bCustom = true; m_styles.push_back(d); fillCombo(QFile::encodeName(newName)); }
void HistoryConfig::copy() { int cur = cmbStyle->currentItem(); if (cur < 0) return; QString name = m_styles[cur].name; QString newName; QRegExp re("\\.[0-9]+$"); unsigned next = 0; for (vector<StyleDef>::iterator it = m_styles.begin(); it != m_styles.end(); ++it){ QString nn = (*it).name; int n = nn.find(re); if (n < 0) continue; nn = nn.mid(n + 1); next = QMAX(next, nn.toUInt()); } int nn = name.find(re); if (nn >= 0){ newName = name.left(nn); }else{ newName = name; } newName += "."; newName += QString::number(next + 1); string n; n = STYLES; n += QFile::encodeName(name); n += EXT; if (m_styles[cur].bCustom){ n = user_file(n.c_str()); }else{ n = app_file(n.c_str()); } QFile from(QFile::decodeName(n.c_str())); if (!from.open(IO_ReadOnly)){ log(L_WARN, "Can't open %s", n.c_str()); return; } n = STYLES; n += QFile::encodeName(newName); n += EXT; n = user_file(n.c_str()); QFile to(QFile::decodeName((n + BACKUP_SUFFIX).c_str())); if (!to.open(IO_WriteOnly | IO_Truncate)){ log(L_WARN, "Cam't create %s", n.c_str()); return; } string s; s.append(from.size(), '\x00'); from.readBlock((char*)(s.c_str()), from.size()); to.writeBlock(s.c_str(), s.length()); from.close(); const int status = to.status(); #if QT_VERSION >= 0x030200 const QString errorMessage = to.errorString(); #else const QString errorMessage = "write file fail"; #endif to.close(); if (status != IO_Ok) { log(L_ERROR, "IO error during writting to file %s : %s", (const char*)to.name().local8Bit(), (const char*)errorMessage.local8Bit()); return; } // rename to normal file QFileInfo fileInfo(to.name()); QString desiredFileName = QFile::decodeName(n.c_str()); if (!fileInfo.dir().rename(fileInfo.fileName(), desiredFileName)) { log(L_ERROR, "Can't rename file %s to %s", (const char*)fileInfo.fileName().local8Bit(), (const char*)desiredFileName.local8Bit()); return; } s = ""; StyleDef d; d.name = newName; d.bCustom = true; m_styles.push_back(d); fillCombo(QFile::encodeName(newName)); }
void PluginManagerPrivate::load(pluginInfo &info) { if (info.module == NULL){ #ifdef WIN32 string pluginName = "plugins\\"; #else string pluginName = "plugins/"; #endif pluginName += info.name; #ifdef WIN32 pluginName += ".dll"; #else pluginName += ".so"; #endif string fullName = app_file(pluginName.c_str()); #ifdef WIN32 HINSTANCE hLib = LoadLibraryA(fullName.c_str()); if (hLib == NULL){ log(L_WARN, "Can't load plugin %s", fullName.c_str()); return; } info.module = (void*)hLib; #else info.module = dlopen(fullName.c_str(), RTLD_LAZY); if (info.module == NULL){ log(L_WARN, "Can't load plugin %s: %s", fullName.c_str(), dlerror()); return; } #endif } if (info.module == NULL) return; if (info.info == NULL){ PluginInfo* (*getInfo)() = NULL; #ifdef WIN32 (DWORD&)getInfo = (DWORD)GetProcAddress((HINSTANCE)info.module,"GetPluginInfo"); #else (void*)getInfo = dlsym(info.module, "GetPluginInfo"); #endif if (getInfo == NULL){ log(L_WARN, "Plugin %s haven't entry GetInfo", info.name); release(info); return; } info.info = getInfo(); #ifndef WIN32 #ifdef USE_KDE if (!(info.info->flags & PLUGIN_KDE_COMPILE)){ log(L_WARN, "Plugin %s compile without KDE support", info.name); release(info); return; } #else if (info.info->flags & PLUGIN_KDE_COMPILE){ log(L_WARN, "Plugin %s compile with KDE support", info.name); release(info); return; } #endif #endif } }