void KviApplication::setupBegin()
{
	//We must do the setup...ask the user..
	QString szSetupLib;

#ifdef KVIRC_MODULES_DIR
	szSetupLib = KVIRC_MODULES_DIR;
#else
	getGlobalKvircDirectory(szSetupLib, KviApplication::Modules);
#endif

	KviQString::ensureLastCharIs(szSetupLib, KVI_PATH_SEPARATOR_CHAR);

#if defined(COMPILE_ON_WINDOWS)
	szSetupLib.append("kvisetup.dll");
#elif defined(COMPILE_ON_MINGW)
	szSetupLib.append("libkvisetup.dll");
#else
	szSetupLib.append("libkvisetup.so");
#endif
	g_pSetupLibrary = new QLibrary(szSetupLib);
	if(!g_pSetupLibrary->load())
	{
		KviMessageBox::warning(__tr2qs("Oops! It looks like I can't load modules on this system.\n"
		                               "I have been looking for the %s library but I haven't been able to load it\n"
		                               "due to the following error: \"%s\"\nAborting."),
		    szSetupLib.toUtf8().data(), g_pSetupLibrary->errorString().toUtf8().data());
#if defined(COMPILE_ON_WINDOWS)
		ExitProcess(-1);
#elif defined(COMPILE_ON_MINGW)
		ExitProcess(1);
#else
		::exit(-1);
#endif
	}

	bool (*sfunc)() = (bool (*)())g_pSetupLibrary->resolve("setup_begin");
	if(!sfunc)
	{
		KviMessageBox::warning(__tr2qs("Oops! It looks like you have a broken distribution.\n"
		                               "The setup module does not export the \"setup_begin\" function.\n"
		                               "Aborting!"));
#if defined(COMPILE_ON_WINDOWS)
		ExitProcess(-1);
#elif defined(COMPILE_ON_MINGW)
		ExitProcess(1);
#else
		::exit(-1);
#endif
	}

	bool bRet = sfunc();

	if(!bRet)
	{
#if defined(COMPILE_ON_WINDOWS)
		ExitProcess(-1);
#elif defined(COMPILE_ON_MINGW)
		ExitProcess(1);
#else
		::exit(-1);
#endif
	}

}
Exemple #2
0
bool KviIsOnNotifyListManager::handleUserhost(KviIrcMessage * msg)
{
	if(!m_bExpectingUserhost)
		return false;
	// first check for consistency: all the replies must be on the USERHOST list

	std::map<std::size_t, std::unique_ptr<KviIrcMask>> tmplist;

	KviCString nk;
	const char * aux = msg->trailing();

	while(*aux)
	{
		nk = "";
		aux = kvi_extractToken(nk, aux, ' ');
		if(nk.hasData())
		{
			// split it in a mask
			KviCString nick;
			KviCString user;
			KviCString host;

			int idx = nk.findFirstIdx('=');
			if(idx != -1)
			{
				nick = nk.left(idx);
				if(nick.lastCharIs('*'))
					nick.cutRight(1);
				nk.cutLeft(idx + 1);
				if(nk.firstCharIs('+') || nk.firstCharIs('-'))
					nk.cutLeft(1);

				idx = nk.findFirstIdx('@');
				if(idx != -1)
				{
					user = nk.left(idx);
					nk.cutLeft(idx + 1);
					host = nk;
				}
				else
				{
					user = "******";
					host = nk;
				}

				bool bGotIt = false;
				QString szNick = m_pConnection->decodeText(nick.ptr());
				QString szUser = m_pConnection->decodeText(user.ptr());
				QString szHost = m_pConnection->decodeText(host.ptr());

				std::size_t i = 0;
				for(const auto & s : m_UserhostList)
				{
					if(KviQString::equalCI(s, szNick))
					{
						tmplist.emplace(i, std::make_unique<KviIrcMask>(szNick, szUser, szHost));
						bGotIt = true;
						break;
					}
				}

				if(!bGotIt)
				{
					// oops... not my userhost!
					if(_OUTPUT_VERBOSE)
						m_pConsole->output(KVI_OUT_SYSTEMWARNING, __tr2qs("Notify list: Hey! You've used USERHOST behind my back? (I might be confused now...)"));
					return false;
				}
			}
			else
			{
				if(_OUTPUT_VERBOSE)
					m_pConsole->output(KVI_OUT_SYSTEMWARNING, __tr2qs("Notify list: Broken USERHOST reply from the server? (%s)"), nk.ptr());
			}
		}
	}

	// Ok... looks to be my usershot (still not sure at 100%, but can't do better)

	if(m_pConnection->lagMeter())
		m_pConnection->lagMeter()->lagCheckComplete("@notify_userhost");

	m_bExpectingUserhost = false;

	for(auto & pair : tmplist)
	{
		KviIrcMask * mk = pair.second.get();

		if(!doMatchUser(mk->nick(), *mk))
			return true; // have to restart!!!
	}

	for(auto i = tmplist.rbegin(); i != tmplist.rend(); ++i)
		m_UserhostList.erase(m_UserhostList.begin() + i->first);

	for(const auto & s : m_UserhostList)
	{
		// oops... someone is no longer online ?
		if(_OUTPUT_VERBOSE)
			m_pConsole->output(KVI_OUT_SYSTEMMESSAGE, __tr2qs("Notify list: \r!n\r%Q\r appears to have gone offline before USERHOST reply was received, will recheck in the next loop"), &s);
	}

	m_UserhostList.clear();

	if(m_OnlineList.empty())
	{
		if(m_NotifyList.empty())
			delayedNotifySession();
		else
			delayedIsOnSession();
	}
	else
	{
		delayedUserhostSession();
	}

	return true;
}
void KviIrcView::doLinkToolTip(const QRect &rct,QString &linkCmd,QString &linkText)
{
	if(linkCmd.isEmpty())return;

	QString szCmd(linkCmd);
	szCmd.remove(0,1);

	QString tip;

	switch(linkCmd[0].unicode())
	{
		case 'u': // url link
		{
			if(!KVI_OPTION_BOOL(KviOption_boolEnableUrlLinkToolTip))
				return;
			tip = "<table width=\"100%\">" \
				"<tr><td valign=\"center\"><img src=\"" + g_pIconManager->getSmallIconResourceName(KviIconManager::Url) + "\"><u><p style=\"white-space:pre;color:#0022FF\">";
			if(linkText.length() > 50)
			{
				tip += linkText.left(47);
				tip += "...";
			} else {
				tip += linkText;
			}
			tip+="</p></u></td></tr><tr><td><hr>";

			// Check clicks' number
			if(KVI_OPTION_UINT(KviOption_uintUrlMouseClickNum) == 1)
				tip += __tr2qs("Click to open this link");
			else
				tip += __tr2qs("Double-click to open this link");
			tip += "</td></tr></table>";
		}
		break;
		case 'h': // host link
		{
			if(!KVI_OPTION_BOOL(KviOption_boolEnableHostLinkToolTip))
				return;
			tip = "<table width=\"100%\">" \
				"<tr><td valign=\"center\"><img src=\"" + g_pIconManager->getSmallIconResourceName(KviIconManager::Server) + "\"><u><p style=\"white-space:pre;color:#0022FF\">";
			if(linkText.length() > 50)
			{
				tip += linkText.left(47);
				tip += "...";
			} else {
				tip += linkText;
			}
			tip+="</p></u></td></tr><tr><td><hr>";

			if(linkText.indexOf('*') != -1)
			{
				if(linkText.length() > 1)tip += __tr2qs("Unable to look up hostname: hostname appears to be masked");
				else tip += __tr2qs("Unable to look up hostname: unknown host");
			} else {
				tip += __tr2qs("Double-click to look up this hostname<br>Right-click to view other options");
			}
			tip += "</td></tr></table>";
		}
		break;
		case 's': // server link
		{
			if(!KVI_OPTION_BOOL(KviOption_boolEnableServerLinkToolTip))
				return;
			// FIXME: #warning "Spit out some server info...hub ?...registered ?"

			tip = "<table width=\"100%\">" \
				"<tr><td valign=\"center\"><img src=\"" + g_pIconManager->getSmallIconResourceName(KviIconManager::Server) + "\"><u><p style=\"white-space:pre;color:#0022FF\">";

			if(linkText.length() > 50)
			{
				tip += linkText.left(47);
				tip += "...";
			} else {
				tip += linkText;
			}
			tip+="</p></u></td></tr><tr><td><hr>";

			if(linkText.indexOf('*') != -1)
			{
				if(linkText.length() > 1)tip += __tr2qs("Server appears to be a network hub<br>");
				else tip += __tr2qs("Unknown server<br>"); // might happen...
			}

			tip.append(__tr2qs("Double-click to read the MOTD<br>Right-click to view other options"));
			tip += "</td></tr></table>";
		}
		break;
		case 'm': // mode link
		{
			if(!KVI_OPTION_BOOL(KviOption_boolEnableModeLinkToolTip))
				return;
			if((linkCmd.length() > 2) && (m_pKviWindow->type() == KviWindow::Channel))
			{
				if(((KviChannelWindow *)m_pKviWindow)->isMeOp())
				{
					QString part = linkCmd.mid(1);
					KviQString::appendFormatted(tip,QString("<b>mode %Q %Q</b>"),&(m_pKviWindow->windowName()),&part);
				} else {
					// I'm not op...no way
					tip = __tr2qs("You're not an operator: you may not change channel modes");
				}
			}
		}
		break;
		case 'n': // nick link
		{
			if(!KVI_OPTION_BOOL(KviOption_boolEnableNickLinkToolTip))
				return;
			if(console())
			{
				if(console()->connection())
				{
					KviIrcUserEntry * e = console()->connection()->userDataBase()->find(linkText);
					if(e)
					{
						QString buffer;
						console()->getUserTipText(linkText,e,buffer);
						tip = buffer;
					} else tip = QString(__tr2qs("Nothing known about %1")).arg(linkText);
				} else tip = QString(__tr2qs("Nothing known about %1 (no connection)")).arg(linkText);
			}
		}
		break;
		case 'c': // channel link
		{
			if(!KVI_OPTION_BOOL(KviOption_boolEnableChannelLinkToolTip))
				return;
			if(console() && console()->connection())
			{
				QString szChan = linkText;
				QString buf;
				tip = "<img src=\"" + g_pIconManager->getSmallIconResourceName(KviIconManager::Channel) + "\"> ";

				if(szCmd.length()>0) szChan=szCmd;
				KviChannelWindow * c = console()->connection()->findChannel(szChan);
				QString szUrl;
				if(c)
				{
					QString chanMode;
					c->getChannelModeString(chanMode);
					QString topic = KviControlCodes::stripControlBytes(c->topicWidget()->topic());
					KviIrcUrl::join(szUrl,console()->connection()->target()->server());
					szUrl.append(szChan);
					buf = QString(__tr2qs("<b>%1</b><u><p style=\"white-space:pre;color:#0022FF\">"
						"%2</p></u>+%3 (%4 users)<hr>%5")).arg(KviQString::toHtmlEscaped(szChan),KviQString::toHtmlEscaped(szUrl),KviQString::toHtmlEscaped(chanMode)).arg(c->count()).arg(KviQString::toHtmlEscaped(topic));
				} else {
					KviIrcUrl::join(szUrl,console()->connection()->target()->server());
					szUrl.append(szChan);
					buf = QString(__tr2qs("<b>%1</b><u><p style=\"white-space:pre;color:#0022FF\">"
						"%2</p></u><hr>Double-click to join %3<br>Right-click to view other options")).arg(KviQString::toHtmlEscaped(szChan),KviQString::toHtmlEscaped(szUrl),KviQString::toHtmlEscaped(szChan));
				}

				tip += buf;
			}
		}
		break;
		default:
		{
			if(!KVI_OPTION_BOOL(KviOption_boolEnableEscapeLinkToolTip))
				return;
			QString dbl,rbt,txt,mbt;
			getLinkEscapeCommand(dbl,linkCmd,"[!dbl]");
			getLinkEscapeCommand(rbt,linkCmd,"[!rbt]");
			getLinkEscapeCommand(txt,linkCmd,"[!txt]");
			getLinkEscapeCommand(mbt,linkCmd,"[!mbt]");

			if(!txt.isEmpty())tip = txt;
			if(tip.isEmpty() && (!dbl.isEmpty()))
			{
				if(!tip.isEmpty())tip.append("<hr>");
				KviQString::appendFormatted(tip,__tr2qs("<b>Double-click:</b><br>%Q"),&dbl);
			}
			if(tip.isEmpty() && (!mbt.isEmpty()))
			{
				if(!tip.isEmpty())tip.append("<hr>");
				KviQString::appendFormatted(tip,__tr2qs("<b>Middle-click:</b><br>%Q"),&mbt);
			}
			if(tip.isEmpty() && (!rbt.isEmpty()))
			{
				if(!tip.isEmpty())tip.append("<hr>");
				KviQString::appendFormatted(tip,__tr2qs("<b>Right-click:</b><br>%Q"),&rbt);
			}
		}
		break;
	}

	if(tip.isEmpty())return;

	m_pToolTip->doTip(rct,tip);
}
Exemple #4
0
bool KviWatchNotifyListManager::doMatchUser(KviIrcMessage * msg, const QString & notifyString, const KviIrcMask & mask)
{
	const auto m = m_pRegUserDict.find(notifyString);
	if(m != m_pRegUserDict.end())
	{
		const QString & nam = m->second;
		// ok... find the user
		if(KviRegisteredUser * u = g_pRegisteredUserDataBase->findUserByName(nam))
		{
			// ok... match the user
			if(u->matchesFixed(mask))
			{
				// new user online
				if(!(m_pConsole->notifyListView()->findEntry(mask.nick())))
				{
					notifyOnLine(mask.nick(), mask.user(), mask.host(), "watch");
				}
				else
				{
					// else already online, and matching... all ok
					if(msg->numeric() == RPL_NOWON)
					{
						// This is a reply to a /watch +something (should not happen, unless the user is messing) or to /watch l (user requested)
						notifyOnLine(mask.nick(), mask.user(), mask.host(),
						    __tr2qs("watch entry listing requested by user"), false);
					}
					else
					{
						// This is a RPL_LOGON.... we're desynched ?
						notifyOnLine(mask.nick(), mask.user(), mask.host(),
						    __tr2qs("possible watch list desync"), false);
					}
				}
			}
			else
			{
				// not matched.... has he been online before ?
				if(m_pConsole->notifyListView()->findEntry(mask.nick()))
				{
					// has been online just a sec ago, but now the mask does not match
					// prolly the reguserdb has been changed
					notifyOffLine(mask.nick(), mask.user(), mask.host(),
					    __tr2qs("registration mask changed or desync with the watch service"));
				}
				else
				{
					// has never been online
					if(_OUTPUT_VERBOSE)
						m_pConsole->output(KVI_OUT_SYSTEMMESSAGE,
						    __tr("Notify list: \r!n\r%Q\r appears to be online, but the mask [%Q@\r!h\r%Q\r] does not match (watch: registration mask does not match, or nickname is being used by someone else)"),
						    &(mask.nick()), &(mask.user()), &(mask.host()));
				}
			}
		}
		else
		{
			// oops... unexpected inconsistency.... reguser db modified ?
			m_pConsole->output(KVI_OUT_SYSTEMWARNING,
			    __tr2qs("Notify list: Unexpected inconsistency, registered user DB modified? (watch: restarting)"));
			stop();
			start();
			return false; // critical... exit from the call stack
		}
	}
	else
	{
		// not in our dictionary
		// prolly someone used /WATCH behind our back... bad boy!
		if(!(m_pConsole->notifyListView()->findEntry(mask.nick())))
		{
			notifyOnLine(mask.nick(), mask.user(), mask.host(), __tr2qs("watch entry added by user"));
		}
	}
	return true;
}
Exemple #5
0
void KviNotifyListManager::notifyOnLine(const QString & szNick, const QString & szUser, const QString & szHost, const QString & szReason, bool bJoin)
{
	if(bJoin)
		m_pConsole->notifyListView()->join(szNick, szUser, szHost);

	KviWindow * pOut = KVI_OPTION_BOOL(KviOption_boolNotifyListChangesToActiveWindow) ? m_pConsole->activeWindow() : m_pConsole;
	if(KVS_TRIGGER_EVENT_1_HALTED(KviEvent_OnNotifyOnLine, pOut, szNick))
		return;

	QString szWho;
	QString szMsg;

	if(!(szUser.isEmpty() || szHost.isEmpty()))
		szWho = QString("\r!n\r%1\r [%2@\r!h\r%3\r]").arg(szNick, szUser, szHost);
	else
		szWho = QString("\r!n\r%1\r").arg(szNick);

	KviPointerHashTable<QString, KviRegisteredUser> * d = g_pRegisteredUserDataBase->userDict();
	KviPointerHashTableIterator<QString, KviRegisteredUser> it(*d);

	while(KviRegisteredUser * pUser = it.current())
	{
		QString szProp = pUser->getProperty("notify");
		if(!szProp.isEmpty() && szProp.split(',', QString::SkipEmptyParts).contains(szNick))
		{
			QString szComment = pUser->getProperty("comment");
			if(!szComment.isEmpty())
				szMsg = QString("%1 (%2), Group \"%3\" is on IRC as (%4)").arg(pUser->name(), szComment, pUser->group(), szWho);
			else
				szMsg = QString("%1, Group \"%2\" is on IRC as (%3)").arg(pUser->name(), pUser->group(), szWho);
			break;
		}
		++it;
	}

	QString szFmt = __tr2qs("%1 is on IRC");

	if(szMsg.isEmpty())
		szMsg = QString(szFmt).arg(szWho);

	if((!szReason.isEmpty()) && (_OUTPUT_VERBOSE))
	{
		szMsg += '(';
		szMsg += szReason;
		szMsg += ')';
	}

	pOut->outputNoFmt(KVI_OUT_NOTIFYONLINE, szMsg);

	if(!(pOut->hasAttention(KviWindow::MainWindowIsVisible)))
	{
		if(KVI_OPTION_BOOL(KviOption_boolFlashWindowOnNotifyOnLine))
			pOut->demandAttention();
		if(KVI_OPTION_BOOL(KviOption_boolPopupNotifierOnNotifyOnLine))
		{
			szWho = "<b>";
			szWho += szNick;
			szWho += "</b>";
			szMsg = QString(szFmt).arg(szWho);
			g_pApp->notifierMessage(pOut, KVI_OPTION_MSGTYPE(KVI_OUT_NOTIFYONLINE).pixId(), szMsg, KVI_OPTION_UINT(KviOption_uintNotifierAutoHideTime));
		}
	}
}
Exemple #6
0
KviDefaultScriptDialog::KviDefaultScriptDialog()
: QDialog()
{
	setObjectName("restore_default_script");
	setWindowTitle(__tr2qs("Restore Default Script - KVIrc"));
	setWindowModality(Qt::WindowModal);
	setModal(true);

	QGridLayout * pLayout = new QGridLayout(this);

	QLabel * pLabel = new QLabel(this);
	pLabel->setText(__tr2qs("You are about to restore the default script.\nAny script changes you have made will be erased if\nrestore \"All\" or \"Clear Custom Scripts\" are selected.\n\nDo you wish to proceed?\n"));
	pLayout->addWidget(pLabel,0,0,1,4);

	// Construct the advanced widget
	m_pAdvanced = new QGroupBox(__tr2qs("Select the Items to Restore"),this);
	m_pAdvanced->hide();

	QGridLayout * pAdvLayout = new QGridLayout(m_pAdvanced);
	pAdvLayout->setContentsMargins(0,10,0,0);
	pLayout->addWidget(m_pAdvanced,1,0,1,4);

	m_pAll = new QCheckBox(__tr2qs("All"),m_pAdvanced);
	m_pAll->setChecked(true);
	pAdvLayout->addWidget(m_pAll,0,0);
	connect(m_pAll,SIGNAL(clicked(bool)),this,SLOT(toggleAll(bool)));

	m_pData = new QCheckBox(__tr2qs("Clear Custom Scripts"),m_pAdvanced);
	m_pData->setChecked(false);
	m_pData->setEnabled(true);
	pAdvLayout->addWidget(m_pData,0,1);

	pLabel = new QLabel(m_pAdvanced);
	pAdvLayout->addWidget(pLabel,1,1,1,2);

	m_pAction = new QCheckBox(__tr2qs("Actions"),m_pAdvanced);
	m_pAction->setChecked(true);
	m_pAction->setEnabled(false);
	pAdvLayout->addWidget(m_pAction,2,0);

	m_pAddon = new QCheckBox(__tr2qs("Addons"),m_pAdvanced);
	m_pAddon->setChecked(true);
	m_pAddon->setEnabled(false);
	pAdvLayout->addWidget(m_pAddon,2,1);

	m_pAlias = new QCheckBox(__tr2qs("Aliases"),m_pAdvanced);
	m_pAlias->setChecked(true);
	m_pAlias->setEnabled(false);
	pAdvLayout->addWidget(m_pAlias,3,0);

	m_pClass = new QCheckBox(__tr2qs("Classes"),m_pAdvanced);
	m_pClass->setChecked(true);
	m_pClass->setEnabled(false);
	pAdvLayout->addWidget(m_pClass,3,1);

	m_pEvent = new QCheckBox(__tr2qs("Events"),m_pAdvanced);
	m_pEvent->setChecked(true);
	m_pEvent->setEnabled(false);
	pAdvLayout->addWidget(m_pEvent,4,0);

	m_pPopup = new QCheckBox(__tr2qs("Popups"),m_pAdvanced);
	m_pPopup->setChecked(true);
	m_pPopup->setEnabled(false);
	pAdvLayout->addWidget(m_pPopup,4,1);

	m_pRaw = new QCheckBox(__tr2qs("Raw Events"),m_pAdvanced);
	m_pRaw->setChecked(true);
	m_pRaw->setEnabled(false);
	pAdvLayout->addWidget(m_pRaw,5,0);

	m_pToolbar = new QCheckBox(__tr2qs("Toolbars"),m_pAdvanced);
	m_pToolbar->setChecked(true);
	m_pToolbar->setEnabled(false);
	pAdvLayout->addWidget(m_pToolbar,5,1);

	m_pAdvanced->setLayout(pAdvLayout);

	QPixmap * pImage = g_pIconManager->getSmallIcon(150);
	QPushButton * pAdvanced = new QPushButton(*pImage,__tr2qs("Advanced..."),this);
	connect(pAdvanced,SIGNAL(clicked()),this,SLOT(advanced()));
	pLayout->addWidget(pAdvanced,2,0,1,1);

	pImage = g_pIconManager->getSmallIcon(44);
	QPushButton * pCancel = new QPushButton(*pImage,__tr2qs("Cancel"),this);
	pCancel->setDefault(true);
	connect(pCancel,SIGNAL(clicked()),this,SLOT(reject()));
	pLayout->addWidget(pCancel,2,2,1,1);

	pImage = g_pIconManager->getSmallIcon(43);
	QPushButton * pAccept = new QPushButton(*pImage,__tr2qs("Restore"),this);
	connect(pAccept,SIGNAL(clicked()),this,SLOT(accept()));
	pLayout->addWidget(pAccept,2,3,1,1);
}
bool KviPackageReader::readHeaderInternal(KviFile * pFile, const QString &)
{
	// read the PackageHeader
	// Magic
	char magic[4];

	if(pFile->read(magic, 4) != 4)
		return readError();

	if((magic[0] != 'K') || (magic[1] != 'V') || (magic[2] != 'P') || (magic[3] != 'F'))
	{
		setLastError(__tr2qs("The file specified is not a valid KVIrc package"));
		return false;
	}

	// Version
	kvi_u32_t uVersion;
	if(!pFile->load(uVersion))
		return readError();
	if(uVersion != 0x1)
	{
		setLastError(__tr2qs("The package has an invalid version number, it might have been created by a newer KVIrc"));
		return false;
	}

	// Flags
	kvi_u32_t uFlags;
	if(!pFile->load(uFlags))
		return readError();
	// we ignore them at the moment

	// read PackageInfo
	// InfoFieldCount
	kvi_u32_t uCount;
	if(!pFile->load(uCount))
		return writeError();

	stringInfoFields()->clear();
	binaryInfoFields()->clear();

	kvi_u32_t uIdx = 0;
	while(uIdx < uCount)
	{
		QString szKey;
		if(!pFile->load(szKey))
			return readError();
		kvi_u32_t uFieldType;
		if(!pFile->load(uFieldType))
			return readError();
		switch(uFieldType)
		{
			case KVI_PACKAGE_INFOFIELD_TYPE_STRING:
			{
				QString szValue;
				if(!pFile->load(szValue))
					return readError();
				stringInfoFields()->replace(szKey, new QString(szValue));
			}
			break;
			case KVI_PACKAGE_INFOFIELD_TYPE_BINARYBUFFER:
			{
				QByteArray * pbValue = new QByteArray();
				if(!pFile->load(*pbValue))
				{
					delete pbValue;
					return readError();
				}
				binaryInfoFields()->replace(szKey, pbValue);
			}
			break;
			default:
				setLastError(__tr2qs("Invalid info field: the package is probably corrupt"));
				break;
		}
		uIdx++;
	}

	return true;
}
bool KviRijndaelEngine::init(const char * encKey, int encKeyLen, const char * decKey, int decKeyLen)
{
	if(m_pEncryptCipher)
	{
		delete m_pEncryptCipher;
		m_pEncryptCipher = nullptr;
	}
	if(m_pDecryptCipher)
	{
		delete m_pDecryptCipher;
		m_pDecryptCipher = nullptr;
	}

	if(encKey && (encKeyLen > 0))
	{
		if(!(decKey && (decKeyLen > 0)))
		{
			decKey = encKey;
			decKeyLen = encKeyLen;
		} // else all
	}
	else
	{
		// no encrypt key specified...
		if(decKey && decKeyLen)
		{
			encKey = decKey;
			encKeyLen = decKeyLen;
		}
		else
		{
			// both keys missing
			setLastError(__tr2qs("Missing both encryption and decryption key: at least one is needed"));
			return false;
		}
	}

	KviCString szTmpEncryptKey = KviCString(encKey, encKeyLen);
	KviCString szTmpDecryptKey = KviCString(decKey, decKeyLen);

	m_bEncryptMode = CBC; // default mode
	m_bDecryptMode = CBC; // default mode

	if(kvi_strEqualCIN("ecb:", szTmpEncryptKey.ptr(), 4) && (szTmpEncryptKey.len() > 4))
	{
		szTmpEncryptKey.cutLeft(4);
		m_bEncryptMode = ECB;
	}
	else if(kvi_strEqualCIN("old:", szTmpEncryptKey.ptr(), 4) && (szTmpEncryptKey.len() > 4))
	{
		szTmpEncryptKey.cutLeft(4);
		m_bEncryptMode = OldCBC;
	}
	else if(kvi_strEqualCIN("cbc:", szTmpEncryptKey.ptr(), 4) && (szTmpEncryptKey.len() > 4))
	{
		szTmpEncryptKey.cutLeft(4);
	}

	if(kvi_strEqualCIN("ecb:", szTmpDecryptKey.ptr(), 4) && (szTmpDecryptKey.len() > 4))
	{
		szTmpDecryptKey.cutLeft(4);
		m_bDecryptMode = ECB;
	}
	else if(kvi_strEqualCIN("old:", szTmpDecryptKey.ptr(), 4) && (szTmpDecryptKey.len() > 4))
	{
		szTmpDecryptKey.cutLeft(4);
		m_bDecryptMode = OldCBC;
	}
	else if(kvi_strEqualCIN("cbc:", szTmpDecryptKey.ptr(), 4) && (szTmpDecryptKey.len() > 4))
	{
		szTmpDecryptKey.cutLeft(4);
	}

	int defLen = getKeyLen();

	szTmpEncryptKey.padRight(defLen);
	szTmpDecryptKey.padRight(defLen);

	m_pEncryptCipher = new Rijndael();

	int retVal = m_pEncryptCipher->init(
	    (m_bEncryptMode == ECB) ? Rijndael::ECB : Rijndael::CBC,
	    Rijndael::Encrypt,
	    (unsigned char *)szTmpEncryptKey.ptr(),
	    getKeyLenId());
	if(retVal != RIJNDAEL_SUCCESS)
	{
		delete m_pEncryptCipher;
		m_pEncryptCipher = nullptr;
		setLastErrorFromRijndaelErrorCode(retVal);
		return false;
	}

	m_pDecryptCipher = new Rijndael();
	retVal = m_pDecryptCipher->init(
	    (m_bEncryptMode == ECB) ? Rijndael::ECB : Rijndael::CBC,
	    Rijndael::Decrypt,
	    (unsigned char *)szTmpDecryptKey.ptr(),
	    getKeyLenId());
	if(retVal != RIJNDAEL_SUCCESS)
	{
		delete m_pEncryptCipher;
		m_pEncryptCipher = nullptr;
		delete m_pDecryptCipher;
		m_pDecryptCipher = nullptr;
		setLastErrorFromRijndaelErrorCode(retVal);
		return false;
	}

	return true;
}
Exemple #9
0
void UrlDialog::contextMenu(const QPoint &point)
{
    QMenu p("contextmenu", 0);
	p.addAction(__tr2qs("Configure"),this,SLOT(config()));
	p.exec(point);
}
Exemple #10
0
KviIrcViewToolWidget::KviIrcViewToolWidget(KviIrcView * pParent)
: QWidget(pParent)
{
	m_pIrcView = pParent;
	setAutoFillBackground(true);
	setContentsMargins(0,0,0,0);

	QHBoxLayout * pLayout = new QHBoxLayout(this);
	pLayout->setMargin(2);
	pLayout->setSpacing(2);

	QPushButton * pButton = new QPushButton(QIcon(*g_pIconManager->getSmallIcon(KviIconManager::Close)), QString(),this);
	pButton->setFixedSize(16,16);
	pButton->setFlat(true);
	connect(pButton,SIGNAL(clicked()),m_pIrcView,SLOT(toggleToolWidget()));
	pLayout->addWidget(pButton);

	m_pStringToFind = new KviThemedLineEdit(this, m_pIrcView->parentKviWindow(), "search_lineedit");
	pLayout->addWidget(m_pStringToFind);
	connect(m_pStringToFind,SIGNAL(returnPressed()),this,SLOT(findNext()));
	connect(m_pStringToFind,SIGNAL(textChanged(QString)),this,SLOT(findNextHelper(QString)));

	pButton = new QPushButton(__tr2qs("&Next"),this);
	pButton->setDefault(true);
	connect(pButton,SIGNAL(clicked()),this,SLOT(findNext()));
	pLayout->addWidget(pButton);

	pButton = new QPushButton(__tr2qs("&Previous"),this);
	connect(pButton,SIGNAL(clicked()),this,SLOT(findPrev()));
	pLayout->addWidget(pButton);

	m_pOptionsButton = new QPushButton(this);
	m_pOptionsButton->setText(__tr2qs("&Options"));
	pLayout->addWidget(m_pOptionsButton);

	m_pOptionsWidget = new QMenu(m_pOptionsButton);
	QGridLayout * pOptionsLayout = new QGridLayout(m_pOptionsWidget);
	pOptionsLayout->setSpacing(2);

	connect(m_pOptionsButton, SIGNAL(clicked()), this, SLOT(toggleOptions()));

	// Filter tab

	QLabel * pLabel = new QLabel(__tr2qs("Message types"), m_pOptionsWidget);
	pOptionsLayout->addWidget(pLabel,0,0,1,2);

	m_pFilterView = new QTreeWidget(m_pOptionsWidget);
	m_pFilterView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	m_pFilterView->setRootIsDecorated(false);
	//FIXME hardcoded size sucks
	m_pFilterView->setMinimumSize(QSize(200,150));
	m_pFilterView->setColumnCount(1);
	m_pFilterView->header()->hide();
	pOptionsLayout->addWidget(m_pFilterView,1,0,4,2);

	m_pFilterItems = (KviIrcMessageCheckListItem **)KviMemory::allocate(KVI_NUM_MSGTYPE_OPTIONS * sizeof(KviIrcMessageCheckListItem *));

	for(int i=0;i<KVI_NUM_MSGTYPE_OPTIONS;i++)
	{
		m_pFilterItems[i] = new KviIrcMessageCheckListItem(m_pFilterView,this,i);
	}

	pButton = new QPushButton(__tr2qs("Set &All"),m_pOptionsWidget);
	connect(pButton,SIGNAL(clicked()),this,SLOT(filterEnableAll()));
	pOptionsLayout->addWidget(pButton,6,0);

	pButton = new QPushButton(__tr2qs("Set &None"),m_pOptionsWidget);
	connect(pButton,SIGNAL(clicked()),this,SLOT(filterEnableNone()));
	pOptionsLayout->addWidget(pButton,6,1);

	pButton = new QPushButton(__tr2qs("&Load From..."),m_pOptionsWidget);
	connect(pButton,SIGNAL(clicked()),this,SLOT(filterLoad()));
	pOptionsLayout->addWidget(pButton,7,0);

	pButton = new QPushButton(__tr2qs("&Save As..."),m_pOptionsWidget);
	connect(pButton,SIGNAL(clicked()),this,SLOT(filterSave()));
	pOptionsLayout->addWidget(pButton,7,1);

	pLabel = new QLabel(__tr2qs("Pattern:"),m_pOptionsWidget);
	pOptionsLayout->addWidget(pLabel,8,0);
	m_pSearchMode = new QComboBox(m_pOptionsWidget);
    m_pSearchMode->insertItem(PlainText, __tr2qs("Plain Text"));
    m_pSearchMode->insertItem(Wildcards, __tr2qs("Wildcards"));
    m_pSearchMode->insertItem(RegExp, __tr2qs("RegExp"));
	pOptionsLayout->addWidget(m_pSearchMode,8,1);

	pLabel = new QLabel(__tr2qs("Match:"),m_pOptionsWidget);
	pOptionsLayout->addWidget(pLabel,9,0);

	m_pCaseSensitive = new QCheckBox(__tr2qs("&Case sensitive"),m_pOptionsWidget);
	pOptionsLayout->addWidget(m_pCaseSensitive,9,1);

// 	m_pFindResult = new QLabel(this);
// 	m_pFindResult->setFrameStyle(QFrame::Sunken | QFrame::StyledPanel);
// 	pOptionsLayout->addWidget(m_pFindResult,0,6);

	// Focussing the 'string to find' widget has been moved to the toggle function so that it happens whenever the widget is shown

	KviShortcut::create(Qt::Key_Escape,m_pIrcView,SLOT(toggleToolWidget()),0,Qt::WidgetWithChildrenShortcut);
	KviShortcut::create(KVI_SHORTCUTS_WIN_SEARCH,m_pIrcView,SLOT(toggleToolWidget()),0,Qt::WidgetWithChildrenShortcut);
}
Exemple #11
0
static bool rijndael_module_init(KviModule * m)
{
#ifdef COMPILE_CRYPT_SUPPORT
	g_pEngineList = new KviPointerList<KviCryptEngine>;
	g_pEngineList->setAutoDelete(false);

	QString szFormat = __tr2qs("Cryptographic engine based on the Advanced Encryption Standard (AES) algorithm called Rijndael. "
	                           "<br/>The text is first encrypted with Rijndael and then converted to %1 notation. "
	                           "The keys used are %2 bit long and will be padded with zeros if you provide shorter ones. "
	                           "If only one key is provided, this engine will use it for both encrypting and decrypting. "
	                           "See the Rijndael module documentation for more info on the algorithm used. "
	                           "<br/>This engine works in CBC mode by default: other modes are considered INSECURE and should be avoided. "
	                           "The old pseudo-CBC mode used in KVIrc &lt; 4.2 is still available prefixing your key(s) with \"old:\"; "
	                           "if you want to use ECB mode you must prefix your key(s) with \"ecb:\".");

	// FIXME: Maybe convert this repeated code to a function eh ?

	KviCryptEngineDescription * d = new KviCryptEngineDescription;
	d->m_szName = "Rijndael128Hex";
	d->m_szAuthor = "Szymon Stefanek";
	d->m_szDescription = QString(szFormat).arg(__tr2qs("hexadecimal")).arg(128);
	d->m_iFlags = KviCryptEngine::CanEncrypt | KviCryptEngine::CanDecrypt | KviCryptEngine::WantEncryptKey | KviCryptEngine::WantDecryptKey;
	d->m_allocFunc = allocRijndael128HexEngine;
	d->m_deallocFunc = deallocRijndaelCryptEngine;
	m->registerCryptEngine(d);

	d = new KviCryptEngineDescription;
	d->m_szName = "Rijndael192Hex";
	d->m_szAuthor = "Szymon Stefanek";
	d->m_szDescription = QString(szFormat).arg(__tr2qs("hexadecimal")).arg(192);
	d->m_iFlags = KviCryptEngine::CanEncrypt | KviCryptEngine::CanDecrypt | KviCryptEngine::WantEncryptKey | KviCryptEngine::WantDecryptKey;
	d->m_allocFunc = allocRijndael192HexEngine;
	d->m_deallocFunc = deallocRijndaelCryptEngine;
	m->registerCryptEngine(d);

	d = new KviCryptEngineDescription;
	d->m_szName = "Rijndael256Hex";
	d->m_szAuthor = "Szymon Stefanek";
	d->m_szDescription = QString(szFormat).arg(__tr2qs("hexadecimal")).arg(256);
	d->m_iFlags = KviCryptEngine::CanEncrypt | KviCryptEngine::CanDecrypt | KviCryptEngine::WantEncryptKey | KviCryptEngine::WantDecryptKey;
	d->m_allocFunc = allocRijndael256HexEngine;
	d->m_deallocFunc = deallocRijndaelCryptEngine;
	m->registerCryptEngine(d);

	d = new KviCryptEngineDescription;
	d->m_szName = "Rijndael128Base64";
	d->m_szAuthor = "Szymon Stefanek";
	d->m_szDescription = QString(szFormat).arg(__tr2qs("base64")).arg(128);
	d->m_iFlags = KviCryptEngine::CanEncrypt | KviCryptEngine::CanDecrypt | KviCryptEngine::WantEncryptKey | KviCryptEngine::WantDecryptKey;
	d->m_allocFunc = allocRijndael128Base64Engine;
	d->m_deallocFunc = deallocRijndaelCryptEngine;
	m->registerCryptEngine(d);

	d = new KviCryptEngineDescription;
	d->m_szName = "Rijndael192Base64";
	d->m_szAuthor = "Szymon Stefanek";
	d->m_szDescription = QString(szFormat).arg(__tr2qs("base64")).arg(192);
	d->m_iFlags = KviCryptEngine::CanEncrypt | KviCryptEngine::CanDecrypt | KviCryptEngine::WantEncryptKey | KviCryptEngine::WantDecryptKey;
	d->m_allocFunc = allocRijndael192Base64Engine;
	d->m_deallocFunc = deallocRijndaelCryptEngine;
	m->registerCryptEngine(d);

	d = new KviCryptEngineDescription;
	d->m_szName = "Rijndael256Base64";
	d->m_szAuthor = "Szymon Stefanek";
	d->m_szDescription = QString(szFormat).arg(__tr2qs("base64")).arg(256);
	d->m_iFlags = KviCryptEngine::CanEncrypt | KviCryptEngine::CanDecrypt | KviCryptEngine::WantEncryptKey | KviCryptEngine::WantDecryptKey;
	d->m_allocFunc = allocRijndael256Base64Engine;
	d->m_deallocFunc = deallocRijndaelCryptEngine;
	m->registerCryptEngine(d);

	d = new KviCryptEngineDescription;
	d->m_szName = "Mircryption";
	d->m_szAuthor = "Szymon Stefanek";
	d->m_szDescription = __tr2qs("Popular cryptographic engine based on the Blowfish encryption algorithm. "
	                             "<br/>The text is first encrypted with Blowfish and then converted to base64 notation. "
	                             "The keys used have variable length and are specified as character strings. "
	                             "You can specify keys long up to 56 bytes (448 bits) by default or change this with /option uintMaximumBlowFishKeySize UINT. "
	                             "If only one key is provided, this engine will use it for both encrypting and decrypting. "
	                             "<br/>This engine works in CBC mode by default: if you want to use the old and INSECURE ECB mode you must prefix your key(s) with \"ecb:\" or \"old:\".");
	d->m_iFlags = KviCryptEngine::CanEncrypt | KviCryptEngine::CanDecrypt | KviCryptEngine::WantEncryptKey | KviCryptEngine::WantDecryptKey;
	d->m_allocFunc = allocMircryptionEngine;
	d->m_deallocFunc = deallocRijndaelCryptEngine;
	m->registerCryptEngine(d);

	return true;
#else
	return false;
#endif
}
Exemple #12
0
ThemeManagementDialog::ThemeManagementDialog(QWidget * parent)
: QWidget(parent)
{
	m_pItemDelegate = NULL;
#ifdef COMPILE_WEBKIT_SUPPORT
	m_pWebThemeInterfaceDialog = NULL;
#endif
	setObjectName("theme_options_widget");
	setWindowTitle(__tr2qs_ctx("Manage Themes - KVIrc","theme"));
	setWindowIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Theme)));

	m_pInstance = this;

	//QGridLayout * g = new QGridLayout(this);
	QVBoxLayout * pVBox = new QVBoxLayout(this);
	KviTalHBox * pHBox = new KviTalHBox(this);
	pHBox->setMargin(1);
	pHBox->setSpacing(1);
	//g->addWidget(pHBox,0,0);
	pVBox->addWidget(pHBox);
	QToolButton * pTool;
	QFrame * pSep;

	pTool = new QToolButton(pHBox);
	pTool->setIcon(*(g_pIconManager->getBigIcon(KVI_BIGICON_SAVE)));
	pTool->setIconSize(QSize(32,32));
	pTool->setToolTip(__tr2qs_ctx("Save Current Theme...","theme"));
	connect(pTool,SIGNAL(clicked()),this,SLOT(saveCurrentTheme()));

	pSep = new QFrame(pHBox);
	pSep->setFrameStyle(QFrame::VLine | QFrame::Sunken);
	pSep->setMinimumWidth(12);

	m_pPackThemeButton = new QToolButton(pHBox);
	m_pPackThemeButton->setIcon(*(g_pIconManager->getBigIcon(KVI_BIGICON_PACK)));

	m_pPackThemeButton->setIconSize(QSize(32,32));
	m_pPackThemeButton->setToolTip(__tr2qs_ctx("Export Selected Themes to a Distributable Package","theme"));
	connect(m_pPackThemeButton,SIGNAL(clicked()),this,SLOT(packTheme()));

	m_pDeleteThemeButton = new QToolButton(pHBox);
	m_pDeleteThemeButton->setIcon(*(g_pIconManager->getBigIcon(KVI_BIGICON_REMOVE)));
	m_pDeleteThemeButton->setIconSize(QSize(32,32));
	m_pDeleteThemeButton->setToolTip(__tr2qs_ctx("Delete Selected Themes","theme"));
	connect(m_pDeleteThemeButton,SIGNAL(clicked()),this,SLOT(deleteTheme()));

	pSep = new QFrame(pHBox);
	pSep->setFrameStyle(QFrame::VLine | QFrame::Sunken);
	pSep->setMinimumWidth(12);

	pTool = new QToolButton(pHBox);
	pTool->setIcon(*(g_pIconManager->getBigIcon(KVI_BIGICON_OPEN)));
	pTool->setIconSize(QSize(32,32));
	pTool->setToolTip(__tr2qs_ctx("Install Theme Package From Disk","theme"));
	connect(pTool,SIGNAL(clicked()),this,SLOT(installFromFile()));

	pTool = new QToolButton(pHBox);
	pTool->setIcon(*(g_pIconManager->getBigIcon(KVI_BIGICON_WWW)));
	pTool->setIconSize(QSize(32,32));
	pTool->setToolTip(__tr2qs_ctx("Get More Themes...","theme"));
	connect(pTool,SIGNAL(clicked()),this,SLOT(getMoreThemes()));

	QWidget *w= new QWidget(pHBox);
	w->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum);

	m_pListWidget = new KviTalListWidget(this);
	m_pListWidget->setContextMenuPolicy(Qt::CustomContextMenu);
	m_pItemDelegate = new KviTalIconAndRichTextItemDelegate(m_pListWidget);
	m_pItemDelegate->setDefaultIcon(g_pIconManager->getBigIcon(QString(KVI_BIGICON_THEME)));
	m_pListWidget->setItemDelegate(m_pItemDelegate);
	m_pListWidget->setMinimumHeight(400);
	m_pListWidget->setMinimumWidth(420);

	m_pListWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
	m_pListWidget->setSortingEnabled(true);
	connect(m_pListWidget,SIGNAL(itemDoubleClicked(QListWidgetItem *)),this,SLOT(applyTheme(QListWidgetItem *)));


	//FIXME tooltip
	//connect(m_pListWidget,SIGNAL(tipRequest(QListWidgetItem *,const QPoint &)),this,SLOT(tipRequest(QListWidgetItem *,const QPoint &)));
	connect(m_pListWidget,SIGNAL(customContextMenuRequested(const QPoint &)),
		this,SLOT(contextMenuRequested(const QPoint &)));
	connect(m_pListWidget,SIGNAL(itemSelectionChanged()),this,SLOT(enableDisableButtons()));

	pSep = new QFrame(this);
	pSep->setFrameStyle(QFrame::HLine | QFrame::Sunken);
	pSep->setMinimumWidth(300);
	pSep->setMinimumHeight(8);
	pVBox->addWidget(pSep);

	//g->addWidget(pSep,2,0);

	m_pCurrentInstalledThemeLabel = new QLabel(this);
	m_pCurrentInstalledThemeLabel->setText(__tr2qs_ctx("<b><u>Current Installed Theme:</u> ","theme") + " " + KVI_OPTION_STRING(KviOption_stringIconThemeSubdir) + "</b>");
//	g->addWidget(pLabel,2,0);
	pVBox->addWidget(m_pCurrentInstalledThemeLabel);

	pSep = new QFrame(this);
	pSep->setFrameStyle(QFrame::HLine | QFrame::Sunken);
	pSep->setMinimumWidth(300);

//	g->addWidget(pSep,3,0);
	pVBox->addWidget(pSep);

//	g->addWidget(m_pListWidget,4,0);
	pVBox->addWidget(m_pListWidget);

//	KviDynamicToolTip * tip = new KviDynamicToolTip(m_pListWidget);
//	connect(tip,SIGNAL(tipRequest(KviDynamicToolTip *,const QPoint &)),this,SLOT(tipRequest(KviDynamicToolTip *,const QPoint &)));

	QPushButton * b = new QPushButton(__tr2qs("Close"),this);
	b->setMaximumSize(b->sizeHint().width(),b->sizeHint().height());
	connect(b,SIGNAL(clicked()),this,SLOT(closeClicked()));
//	g->addWidget(b,5,0);
	pVBox->addWidget(b);

//	g->setMargin(1);
//	g->setSpacing(1);
	pVBox->setAlignment(b,Qt::AlignRight);
	fillThemeBox();
	m_pContextPopup = new QMenu(this);

	if(g_rectManagementDialogGeometry.y() < 5)
	{
		g_rectManagementDialogGeometry.setY(5);
	}
	resize(g_rectManagementDialogGeometry.width(),
		g_rectManagementDialogGeometry.height());

	QRect rect = g_pApp->desktop()->screenGeometry(g_pMainWindow);
	move(rect.x() + ((rect.width() - g_rectManagementDialogGeometry.width())/2),rect.y() + ((rect.height() - g_rectManagementDialogGeometry.height())/2));

	new QShortcut(Qt::Key_Escape, this, SLOT(closeClicked()));
}
Exemple #13
0
void KviToolBar::mousePressEvent(QMouseEvent * e)
{
	if(!(e->button() & Qt::RightButton))
	{
		QToolBar::mousePressEvent(e);
		return;
	}

	if(!g_pToolBarContextPopup)
	{
		g_pToolBarContextPopup = new QMenu();
		g_pToolBarIconSizesPopup = new QMenu();
		g_pToolBarWindowsPopup = new QMenu();
		g_pToolBarButtonStylePopup = new QMenu();

		QAction * pAction = g_pToolBarContextPopup->addAction(__tr2qs("Toolbars"));
		pAction->setMenu(g_pToolBarWindowsPopup);
		pAction = g_pToolBarContextPopup->addAction(__tr2qs("Icon Size"));
		pAction->setMenu(g_pToolBarIconSizesPopup);
		pAction = g_pToolBarContextPopup->addAction(__tr2qs("Button Style"));
		pAction->setMenu(g_pToolBarButtonStylePopup);

		// fill toolbars menu
		g_pMainWindow->fillToolBarsPopup(g_pToolBarWindowsPopup);

		// fill icon size menu
		QActionGroup * pIconSizeGroup = new QActionGroup(g_pToolBarIconSizesPopup);

		QAction * pTmp = nullptr;
		IconSizes iconSize;
		for(auto & valid_iconsize : valid_iconsizes)
		{
			iconSize = valid_iconsize;

			pTmp = pIconSizeGroup->addAction(g_pToolBarIconSizesPopup->addAction(__tr2qs(iconSize.pcName)));
			pTmp->setData((uint)iconSize.uSize);
			pTmp->setCheckable(true);
			if(iconSize.uSize == KVI_OPTION_UINT(KviOption_uintToolBarIconSize))
				pTmp->setChecked(true);
		}

		connect(pIconSizeGroup, SIGNAL(triggered(QAction *)), g_pMainWindow, SLOT(iconSizePopupSelected(QAction *)));

		// fill button style menu
		QActionGroup * pButtonStyleGroup = new QActionGroup(g_pToolBarButtonStylePopup);

		pTmp = nullptr;
		ButtonStyles buttonStyle;
		for(auto & valid_buttonstyle : valid_buttonstyles)
		{
			buttonStyle = valid_buttonstyle;

			pTmp = pButtonStyleGroup->addAction(g_pToolBarButtonStylePopup->addAction(__tr2qs(buttonStyle.pcName)));
			pTmp->setData((uint)buttonStyle.uStyle);
			pTmp->setCheckable(true);
			if(buttonStyle.uStyle == KVI_OPTION_UINT(KviOption_uintToolBarButtonStyle))
				pTmp->setChecked(true);
		}

		connect(pButtonStyleGroup, SIGNAL(triggered(QAction *)), g_pMainWindow, SLOT(buttonStylePopupSelected(QAction *)));
	}

	g_pToolBarContextPopup->popup(QCursor::pos());
}
Exemple #14
0
static QString queryWinInfo(QueryInfo info)
{
	QString szVersion;
	OSVERSIONINFOEX osvi;
	SYSTEM_INFO si;
	PGNSI pGNSI;
	BOOL bOsVersionInfoEx;

	ZeroMemory(&si, sizeof(SYSTEM_INFO));
	ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));

	// Try calling GetVersionEx using the OSVERSIONINFOEX structure.
	// If that fails, try using the OSVERSIONINFO structure.

	osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);

	if(!(bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO *)&osvi)))
	{
		osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
		if(!GetVersionEx((OSVERSIONINFO *)&osvi))
			return KviQString::Empty;
	}

	// Call GetNativeSystemInfo if supported or GetSystemInfo otherwise.

	pGNSI = (PGNSI)GetProcAddress(
	    GetModuleHandle(TEXT("kernel32.dll")),
	    "GetNativeSystemInfo");
	if(NULL != pGNSI)
		pGNSI(&si);
	else
		GetSystemInfo(&si);

	switch(osvi.dwPlatformId)
	{
		// Test for the Windows NT product family.

		case VER_PLATFORM_WIN32_NT:

			// Test for the specific product.
			if(osvi.dwMajorVersion == 10 && osvi.dwMinorVersion == 0)
			{
				if(osvi.wProductType == VER_NT_WORKSTATION)
					szVersion += "Windows 10 ";
				else
					szVersion += "Windows Server 2016";
			}

			if(osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 3)
			{
				if(osvi.wProductType == VER_NT_WORKSTATION)
					szVersion += "Windows 8.1 ";
				else
					szVersion += "Windows Server 2012 R2";
			}

			if(osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 2)
			{
				if(osvi.wProductType == VER_NT_WORKSTATION)
					szVersion += "Windows 8 ";
				else
					szVersion += "Windows Server 2012 ";
			}

			if(osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 1)
			{
				if(osvi.wProductType == VER_NT_WORKSTATION)
					szVersion += "Windows 7 ";
				else
					szVersion += "Windows Server 2008 R2 ";
			}

			if(osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0)
			{
				if(osvi.wProductType == VER_NT_WORKSTATION)
					szVersion += "Windows Vista ";
				else
					szVersion += "Windows Server 2008 ";
			}

			if(osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2)
			{
				if(GetSystemMetrics(SM_SERVERR2))
					szVersion += "Windows Server 2003 \"R2\" ";
				else if(osvi.wProductType == VER_NT_WORKSTATION && si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
				{
					szVersion += "Windows XP Professional x64 ";
				}
				else
					szVersion += "Windows Server 2003, ";
			}

			if(osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1)
				szVersion += "Windows XP ";

			PGETPRODUCTINFO pGetProductInfo;
			pGetProductInfo = (PGETPRODUCTINFO)GetProcAddress(
			    GetModuleHandle(TEXT("kernel32.dll")), "GetProductInfo");
			// from MSDN, Document Date 9/7/2012
			// http://msdn.microsoft.com/en-us/library/windows/desktop/ms724358
			// the entire PRODUCT_CORE group has the base Windows version in the
			// returned value. rip out "Windows" of all PRODUCT values as well
			if(bOsVersionInfoEx)
			{
				DWORD dwPlatformInfo;
				if(NULL != pGetProductInfo)
					if(pGetProductInfo(osvi.dwMajorVersion, osvi.dwMinorVersion,
					       osvi.wServicePackMajor, osvi.wServicePackMinor, &dwPlatformInfo))
					{
						switch(dwPlatformInfo)
						{
							case PRODUCT_BUSINESS:
								szVersion += "Business";
								break;
							case PRODUCT_BUSINESS_N:
								szVersion += "Business N";
								break;
							case PRODUCT_CLUSTER_SERVER:
								szVersion += "HPC Edition";
								break;
							case PRODUCT_CLUSTER_SERVER_V:
								szVersion += "Server Hyper Core V";
								break;
							case PRODUCT_CORE:
								//szVersion+="Windows 8";
								break;
							case PRODUCT_CORE_N:
								szVersion += "N";
								break;
							case PRODUCT_CORE_COUNTRYSPECIFIC:
								szVersion += "China";
								break;
							case PRODUCT_CORE_SINGLELANGUAGE:
								szVersion += "Single Language";
								break;
							case PRODUCT_DATACENTER_EVALUATION_SERVER:
								szVersion += "Server Datacenter (evaluation installation)";
								break;
							case PRODUCT_DATACENTER_SERVER:
								szVersion += "Server Datacenter (full installation)";
								break;
							case PRODUCT_DATACENTER_SERVER_CORE:
								szVersion += "Server Datacenter (core installation)";
								break;
							case PRODUCT_DATACENTER_SERVER_CORE_V:
								szVersion += "Server Datacenter without Hyper-V (core installation)";
								break;
							case PRODUCT_DATACENTER_SERVER_V:
								szVersion += "Server Datacenter without Hyper-V (full installation)";
								break;
							case PRODUCT_ENTERPRISE:
								szVersion += "Enterprise";
								break;
							case PRODUCT_ENTERPRISE_E:
								//szVersion+="Not supported";
								break;
							case PRODUCT_ENTERPRISE_N_EVALUATION:
								szVersion += "Enterprise N (evaluation installation)";
								break;
							case PRODUCT_ENTERPRISE_N:
								szVersion += "Enterprise N";
								break;
							case PRODUCT_ENTERPRISE_EVALUATION:
								szVersion += "Server Enterprise (evaluation installation)";
								break;
							case PRODUCT_ENTERPRISE_SERVER:
								szVersion += "Server Enterprise (full installation)";
								break;
							case PRODUCT_ENTERPRISE_SERVER_CORE:
								szVersion += "Server Enterprise (core installation)";
								break;
							case PRODUCT_ENTERPRISE_SERVER_CORE_V:
								szVersion += "Server Enterprise without Hyper-V (core installation)";
								break;
							case PRODUCT_ENTERPRISE_SERVER_IA64:
								szVersion += "Server Enterprise for Itanium-based Systems";
								break;
							case PRODUCT_ENTERPRISE_SERVER_V:
								szVersion += "Server Enterprise without Hyper-V (full installation)";
								break;
							case PRODUCT_ESSENTIALBUSINESS_SERVER_MGMT:
								szVersion += "Essential Server Solution Management";
								break;
							case PRODUCT_ESSENTIALBUSINESS_SERVER_ADDL:
								szVersion += "Essential Server Solution Additional";
								break;
							case PRODUCT_ESSENTIALBUSINESS_SERVER_MGMTSVC:
								szVersion += "Essential Server Solution Management SVC";
								break;
							case PRODUCT_ESSENTIALBUSINESS_SERVER_ADDLSVC:
								szVersion += "Essential Server Solution Additional SVC";
								break;
							case PRODUCT_HOME_BASIC:
								szVersion += "Home Basic";
								break;
							case PRODUCT_HOME_BASIC_E:
								//szVersion+="Not supported";
								break;
							case PRODUCT_HOME_BASIC_N:
								szVersion += "Home Basic N";
								break;
							case PRODUCT_HOME_PREMIUM:
								szVersion += "Home Premium";
								break;
							case PRODUCT_HOME_PREMIUM_E:
								//szVersion+="Not supported";
								break;
							case PRODUCT_HOME_PREMIUM_N:
								szVersion += "Home Premium N";
								break;
							case PRODUCT_HOME_PREMIUM_SERVER:
								szVersion += "Home Server 2011";
								break;
							case PRODUCT_HOME_SERVER:
								szVersion += "Storage Server 2008 R2 Essentials";
								break;
							case PRODUCT_HYPERV:
								szVersion += "Hyper-V Server";
								break;
							case PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT:
								szVersion += "Essential Business Server Management Server";
								break;
							case PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING:
								szVersion += "Essential Business Server Messaging Server";
								break;
							case PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY:
								szVersion += "Essential Business Server Security Server";
								break;
							case PRODUCT_MULTIPOINT_STANDARD_SERVER:
								szVersion += "MultiPoint Server Standard (full installation)";
								break;
							case PRODUCT_MULTIPOINT_PREMIUM_SERVER:
								szVersion += "MultiPoint Server Premium (full installation)";
								break;
							case PRODUCT_PROFESSIONAL:
								szVersion += "Professional";
								break;
							case PRODUCT_PROFESSIONAL_E:
								//szVersion+="Not supported";
								break;
							case PRODUCT_PROFESSIONAL_N:
								szVersion += "Professional N";
								break;
							case PRODUCT_PROFESSIONAL_WMC:
								szVersion += "Professional with Media Center";
								break;
							case PRODUCT_SB_SOLUTION_SERVER_EM:
								szVersion += "Server For SB Solutions EM";
								break;
							case PRODUCT_SERVER_FOR_SB_SOLUTIONS:
								szVersion += "Server For SB Solutions";
								break;
							case PRODUCT_SERVER_FOR_SB_SOLUTIONS_EM:
								szVersion += "Server For SB Solutions EM";
								break;
							case PRODUCT_SERVER_FOR_SMALLBUSINESS:
								szVersion += "Server 2008 for Windows Essential Server Solutions";
								break;
							case PRODUCT_SERVER_FOR_SMALLBUSINESS_V:
								szVersion += "Server 2008 without Hyper-V for Windows Essential Server Solutions";
								break;
							case PRODUCT_SERVER_FOUNDATION:
								szVersion += "Server Foundation";
								break;
							case PRODUCT_SB_SOLUTION_SERVER:
								szVersion += "Small Business Server 2011 Essentials";
								break;
							case PRODUCT_SMALLBUSINESS_SERVER:
								szVersion += "Small Business Server";
								break;
							case PRODUCT_SMALLBUSINESS_SERVER_PREMIUM:
								szVersion += "Small Business Server Premium";
								break;
							case PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE:
								szVersion += "Small Business Server Premium (core installation)";
								break;
							case PRODUCT_SOLUTION_EMBEDDEDSERVER:
								szVersion += "MultiPoint Server";
								break;
							case PRODUCT_STANDARD_EVALUATION_SERVER:
								szVersion += "Server Standard (evaluation installation)";
								break;
							case PRODUCT_STANDARD_SERVER:
								szVersion += "Server Standard";
								break;
							case PRODUCT_STANDARD_SERVER_CORE:
								szVersion += "Server Standard (core installation)";
								break;
							case PRODUCT_STANDARD_SERVER_V:
								szVersion += "Server Standard without Hyper-V";
								break;
							case PRODUCT_STANDARD_SERVER_CORE_V:
								szVersion += "Server Standard without Hyper-V (core installation)";
								break;
							case PRODUCT_STANDARD_SERVER_SOLUTIONS:
								szVersion += "Server Solutions Premium";
								break;
							case PRODUCT_STANDARD_SERVER_SOLUTIONS_CORE:
								szVersion += "Server Solutions Premium (core installation)";
								break;
							case PRODUCT_STARTER:
								szVersion += "Starter";
								break;
							case PRODUCT_STARTER_E:
								//szVersion+="Not supported";
								break;
							case PRODUCT_STARTER_N:
								szVersion += "Starter N";
								break;
							case PRODUCT_STORAGE_ENTERPRISE_SERVER:
								szVersion += "Storage Server Enterprise";
								break;
							case PRODUCT_STORAGE_ENTERPRISE_SERVER_CORE:
								szVersion += "Storage Server Enterprise (core installation)";
								break;
							case PRODUCT_STORAGE_EXPRESS_SERVER:
								szVersion += "Storage Server Express";
								break;
							case PRODUCT_STORAGE_EXPRESS_SERVER_CORE:
								szVersion += "Storage Server Express (core installation)";
								break;
							case PRODUCT_STORAGE_STANDARD_EVALUATION_SERVER:
								szVersion += "Storage Server Standard (evaluation installation)";
								break;
							case PRODUCT_STORAGE_STANDARD_SERVER:
								szVersion += "Storage Server Standard";
								break;
							case PRODUCT_STORAGE_STANDARD_SERVER_CORE:
								szVersion += "Storage Server Standard (core installation)";
								break;
							case PRODUCT_STORAGE_WORKGROUP_EVALUATION_SERVER:
								szVersion += "Storage Server Workgroup (evaluation installation)";
								break;
							case PRODUCT_STORAGE_WORKGROUP_SERVER:
								szVersion += "Storage Server Workgroup";
								break;
							case PRODUCT_STORAGE_WORKGROUP_SERVER_CORE:
								szVersion += "Storage Server Workgroup (core installation)";
								break;
							case PRODUCT_UNDEFINED:
								szVersion += "An unknown product";
								break;
							// just use unknown here since we do not care.
							case PRODUCT_UNLICENSED:
								szVersion += "An unknown product";
								break;
							case PRODUCT_ULTIMATE:
								szVersion += "Ultimate";
								break;
							case PRODUCT_ULTIMATE_E:
								//szVersion+="Not supported";
								break;
							case PRODUCT_ULTIMATE_N:
								szVersion += "Ultimate N";
								break;
							case PRODUCT_WEB_SERVER:
								szVersion += "Web Server (full installation)";
								break;
							case PRODUCT_WEB_SERVER_CORE:
								szVersion += "Web Server (core installation)";
								break;
						}
						szVersion += " ";
						if(si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
						{
							szVersion += "(x64) ";
						}
					}
					else
					{
						// Test for the workstation type, for XP 32 bit
						if(osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1)
						{
							if(osvi.wProductType == VER_NT_WORKSTATION)
							{
								if(osvi.wSuiteMask & VER_SUITE_PERSONAL)
									szVersion += "Home Edition ";
								else
									szVersion += "Professional ";
							}
						}
						// Test for the server type.
						else if(osvi.wProductType == VER_NT_SERVER || osvi.wProductType == VER_NT_DOMAIN_CONTROLLER)
						{
							if(osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2)
							{
								if(si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64)
								{
									if(osvi.wSuiteMask & VER_SUITE_DATACENTER)
										szVersion += "Datacenter Edition for Itanium-based Systems";
									else if(osvi.wSuiteMask & VER_SUITE_ENTERPRISE)
										szVersion += "Enterprise Edition for Itanium-based Systems";
								}

								else if(si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
								{
									if(osvi.wSuiteMask & VER_SUITE_DATACENTER)
										szVersion += "Datacenter x64 Edition ";
									else if(osvi.wSuiteMask & VER_SUITE_ENTERPRISE)
										szVersion += "Enterprise x64 Edition ";
									else
										szVersion += "Standard x64 Edition ";
								}
								else
								{
									if(osvi.wSuiteMask & VER_SUITE_DATACENTER)
										szVersion += "Datacenter Edition ";
									else if(osvi.wSuiteMask & VER_SUITE_ENTERPRISE)
										szVersion += "Enterprise Edition ";
									else if(osvi.wSuiteMask == VER_SUITE_BLADE)
										szVersion += "Web Edition ";
									else
										szVersion += "Standard Edition ";
								}
							}
						}
					}
			}
			// Display service pack (if any) and build number.
			szVersion += QString("%1 (Build %2)").arg(QString::fromWCharArray(osvi.szCSDVersion)).arg(osvi.dwBuildNumber & 0xFFFF);
	}
	if(info == Os_Release)
	{
		unsigned long major = osvi.dwMajorVersion;
		unsigned long minor = osvi.dwMinorVersion;
		unsigned long release = osvi.dwBuildNumber;
		QString szMajor, szMinor, szRelease, szVersion;
		szMajor.setNum(major);
		szMinor.setNum(minor);
		szRelease.setNum(release);
		szVersion = "Release : " + szMajor + "." + szMinor + "." + szRelease;
		return szVersion;
	}
	if(info == Os_Type)
	{
		if(osvi.dwPlatformId == VER_PLATFORM_WIN32_NT)
			return " NT ";
		return __tr2qs("Unknown ");
	}
	if(info == Os_Version)
	{
		return szVersion;
	}

	return KviQString::Empty;
}
Exemple #15
0
void ChannelsJoinDialog::fillListView()
{
	m_pTreeWidget->clear();

	m_pTreeWidget->header()->hide();

	// Registered channels go first

	QTreeWidgetItem * par = new QTreeWidgetItem(m_pTreeWidget, HeaderItem);
	par->setText(0, __tr2qs("Registered Channels"));
	par->setExpanded(true);

	QHash<QString, KviRegisteredChannelList *> * d = g_pRegisteredChannelDataBase->channelDict();
	if(d)
	{
		for(QHash<QString, KviRegisteredChannelList *>::Iterator it = d->begin(); it != d->end(); ++it)
		{
			QTreeWidgetItem * chld = new QTreeWidgetItem(par, RegisteredChannelItem);
			chld->setText(0, it.key());
			chld->setIcon(0, *(g_pIconManager->getSmallIcon(KviIconManager::Channel)));
		}
	}

	par->sortChildren(0, Qt::AscendingOrder);

	par = new QTreeWidgetItem(m_pTreeWidget, HeaderItem);
	par->setText(0, __tr2qs("Recent Channels"));
	par->setExpanded(true);

	QTreeWidgetItem * chld;

	bool bGotChanOnCurrentNetwork = false;

	QTreeWidgetItem * hdr;

	if(m_pConsole)
	{
		QStringList * pList = g_pApp->recentChannelsForNetwork(m_pConsole->currentNetworkName());
		if(pList)
		{
			if(pList->count() > 0)
			{
				bGotChanOnCurrentNetwork = true;

				hdr = new QTreeWidgetItem(par, HeaderItem);
				hdr->setText(0, __tr2qs("Current Network"));
				hdr->setExpanded(true);

				for(auto & it : *pList)
				{
					chld = new QTreeWidgetItem(hdr, RecentChannelItem);
					chld->setText(0, it);
					chld->setIcon(0, *(g_pIconManager->getSmallIcon(KviIconManager::Channel)));
				}
				hdr->sortChildren(0, Qt::AscendingOrder);
			}
		}
	}

	KviPointerHashTable<QString, QStringList> * pDict = g_pApp->recentChannels();
	if(!pDict)
		return;

	hdr = new QTreeWidgetItem(par, HeaderItem);
	hdr->setText(0, __tr2qs("All Networks"));

	if(!bGotChanOnCurrentNetwork)
		hdr->setExpanded(true); // expand this one instead

	QHash<QString, int> hNoDuplicates;

	for(QStringList * pChans = pDict->first(); pChans; pChans = pDict->next())
	{
		for(auto chan : *pChans)
		{
			if(hNoDuplicates.contains(chan.toLower()))
				continue;
			hNoDuplicates.insert(chan.toLower(), 1);
			chld = new QTreeWidgetItem(hdr, RecentChannelItem);
			chld->setText(0, chan);
			chld->setIcon(0, *(g_pIconManager->getSmallIcon(KviIconManager::Channel)));
		}
	}
	hdr->sortChildren(0, Qt::AscendingOrder);
}
Exemple #16
0
void KviWindow::pasteLastLog()
{
	bool bChannel = type() == KviWindow::Channel || type() == KviWindow::DeadChannel;
	QDate date = QDate::currentDate();
	int iInterval = -(int)KVI_OPTION_UINT(bChannel ? KviOption_uintDaysIntervalToPasteOnChannelJoin : KviOption_uintDaysIntervalToPasteOnQueryJoin);
	QDate checkDate = date.addDays(iInterval);

	unsigned int uMaxLines = KVI_OPTION_UINT(bChannel ? KviOption_uintLinesToPasteOnChannelJoin : KviOption_uintLinesToPasteOnQueryJoin);
	if (!uMaxLines)
		return;

	std::vector<std::tuple<QString, QDate, int>> vLines;

	for (; date >= checkDate; date = date.addDays(-1))
		for (int iGzip = 0; iGzip <= 1; iGzip++)
			for (unsigned int uDatetimeFormat = 0; uDatetimeFormat < 3; uDatetimeFormat++)
			{
				bool bGzip = !!iGzip;

				QString szFileName;
				getDefaultLogFileName(szFileName, date, bGzip, uDatetimeFormat);

				QFileInfo fi(szFileName);
				if (!fi.exists() || !fi.isFile())
					continue;

				// Load the log
				QByteArray log = loadLogFile(szFileName, bGzip);

				if(log.size() == 0)
					continue;

				QList<QByteArray> list = log.split('\n');
				unsigned int uCount = list.size();

				while (uCount)
				{
					vLines.emplace_back(QString(list.at(--uCount)), date, uDatetimeFormat);

					if (vLines.size() == uMaxLines)
						goto enough;
				}
			}

	if (vLines.empty())
		return;

enough:
	QString szDummy = __tr2qs("Starting last log");
	output(KVI_OUT_LOG, szDummy);

	for (auto logIter = vLines.rbegin(); logIter != vLines.rend(); ++logIter)
	{
		QString & szLine      = std::get<0>(*logIter);
		const QDate & logDate = std::get<1>(*logIter);
		int uDatetimeFormat   = std::get<2>(*logIter);

		bool ok;
		int msgType = szLine.section(' ', 0, 0).toInt(&ok);
		if (ok)
			szLine = szLine.section(' ', 1);
		else
			msgType = KVI_OUT_LOG;

		QDateTime date;
		switch(uDatetimeFormat)
		{
			case 0:
			{
				QTime time = QTime::fromString(szLine.section(' ', 0, 0), "[hh:mm:ss]");
				if (time.isValid())
				{
					date = QDateTime(logDate, time);
					szLine = szLine.section(' ', 1);
				}
				break;
			}
			case 1:
				date = QDateTime::fromString(szLine.section(' ', 0, 0), Qt::ISODate);
				if (date.isValid())
					szLine = szLine.section(' ', 1);
				break;
			case 2:
			{
				// The system-locale format is hairy, because it has no clear delimiter.
				// Count how many spaces a typical time format has,
				// and assume that that number is not going to change.
				static int iSpaceCount = -1;
				if (iSpaceCount == -1)
				{
					QString szTypicalDate = QDateTime::currentDateTime().toString(Qt::SystemLocaleShortDate);
					iSpaceCount = szTypicalDate.count(' ');
				}
				date = QDateTime::fromString(szLine.section(' ', 0, iSpaceCount), Qt::SystemLocaleShortDate);
				if (date.isValid())
				{
					szLine = szLine.section(' ', iSpaceCount+1);

					// Work around Qt bug:
					// if the date string contains a two-digit year, it may be
					// parsed in the wrong century (i.e. 1916 instead of 2016).
					if (logDate.year() == date.date().year() + 100)
						date = date.addYears(100);
				}
				break;
			}
		}

		if (szLine.isEmpty())
			continue;

		// Print the line in the channel buffer
		output(msgType, date, "%Q", &szLine);
	}

	szDummy = __tr2qs("End of log");
	output(KVI_OUT_LOG, szDummy);
}
Exemple #17
0
ChannelsJoinDialog::ChannelsJoinDialog(const char * name)
    : QDialog(g_pMainWindow)
{
	setObjectName(name);
	setWindowTitle(__tr2qs("Join Channels - KVIrc"));
	setWindowIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Channel)));

	m_pConsole = nullptr;

	QGridLayout * g = new QGridLayout(this);

	m_pTreeWidget = new ChannelsJoinDialogTreeWidget(this);
	m_pTreeWidget->setHeaderLabel(__tr2qs("Channel"));
	m_pTreeWidget->setRootIsDecorated(true);
	m_pTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
	g->addWidget(m_pTreeWidget, 0, 0, 1, 2);

	m_pGroupBox = new KviTalGroupBox(Qt::Horizontal, __tr2qs("Channel"), this);
	QString szMsg = __tr2qs("Name");
	szMsg.append(":");

	new QLabel(szMsg, m_pGroupBox);

	m_pChannelEdit = new QLineEdit(m_pGroupBox);
	connect(m_pChannelEdit, SIGNAL(returnPressed()), this, SLOT(editReturnPressed()));
	connect(m_pChannelEdit, SIGNAL(textChanged(const QString &)), this, SLOT(editTextChanged(const QString &)));

	szMsg = __tr2qs("Password");
	szMsg.append(":");

	new QLabel(szMsg, m_pGroupBox);

	m_pPass = new QLineEdit(m_pGroupBox);
	m_pPass->setEchoMode(QLineEdit::Password);

	g->addWidget(m_pGroupBox, 1, 0, 1, 2);

	KviTalHBox * hb = new KviTalHBox(this);
	hb->setSpacing(4);

	g->addWidget(hb, 2, 0, 1, 2);

	m_pJoinButton = new QPushButton(__tr2qs("&Join"), hb);
	// Join on return pressed
	m_pJoinButton->setDefault(true);
	connect(m_pJoinButton, SIGNAL(clicked()), this, SLOT(joinClicked()));

	m_pRegButton = new QPushButton(__tr2qs("&Register"), hb);
	// Join on return pressed
	connect(m_pRegButton, SIGNAL(clicked()), this, SLOT(regClicked()));

	m_pClearButton = new QPushButton(__tr2qs("Clear Recent"), hb);
	connect(m_pClearButton, SIGNAL(clicked()), this, SLOT(clearClicked()));

	m_pShowAtStartupCheck = new QCheckBox(__tr2qs("Show this window after connecting"), this);
	m_pShowAtStartupCheck->setChecked(KVI_OPTION_BOOL(KviOption_boolShowChannelsJoinOnIrc));
	g->addWidget(m_pShowAtStartupCheck, 3, 0);

	QPushButton * cancelButton = new QPushButton(__tr2qs("Close"), this);
	connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancelClicked()));

	g->addWidget(cancelButton, 3, 1, Qt::AlignRight);

	g->setRowStretch(0, 1);
	g->setColumnStretch(0, 1);

	fillListView();

	if(g_rectChannelsJoinGeometry.y() < 5)
		g_rectChannelsJoinGeometry.setY(5);

	resize(g_rectChannelsJoinGeometry.width(), g_rectChannelsJoinGeometry.height());

	QRect rect = g_pApp->desktop()->screenGeometry(g_pMainWindow);
	move(rect.x() + ((rect.width() - g_rectChannelsJoinGeometry.width()) / 2), rect.y() + ((rect.height() - g_rectChannelsJoinGeometry.height()) / 2));

	enableJoin();
}
Exemple #18
0
// This is always defined...
void KviWindow::createCryptControllerButton(QWidget *)
{
#ifdef COMPILE_CRYPT_SUPPORT
	m_pCryptControllerButton = new KviWindowToolPageButton(KviIconManager::UnLockedOff, KviIconManager::UnLocked, __tr2qs("Encryption"), buttonContainer(), false);
	m_pCryptControllerButton->setObjectName("crypt_controller_button");
	connect(m_pCryptControllerButton, SIGNAL(clicked()), this, SLOT(toggleCryptController()));
#endif // COMPILE_CRYPT_SUPPORT
}
bool KviPackageReader::unpackFile(KviFile * pFile, const QString & szUnpackPath)
{
	// Flags
	kvi_u32_t uFlags;
	if(!pFile->load(uFlags))
		return readError();

#ifndef COMPILE_ZLIB_SUPPORT
	if(uFlags & KVI_PACKAGE_DATAFIELD_FLAG_FILE_DEFLATE)
	{
		setLastError(__tr2qs("The package contains compressed data but this executable does not support compression"));
		return false;
	}
#endif

	// Path
	QString szPath;
	if(!pFile->load(szPath))
		return readError();

	QString szFileName = szUnpackPath;
	KviQString::ensureLastCharIs(szFileName, QChar(KVI_PATH_SEPARATOR_CHAR));

	szFileName += szPath;

	// no attacks please :)
	szFileName.replace(QString("..\\"), QString(""));
	szFileName.replace(QString("../"), QString(""));

	KviFileUtils::adjustFilePath(szFileName);

	int idx = szFileName.lastIndexOf(QChar(KVI_PATH_SEPARATOR_CHAR));
	if(idx != -1)
	{
		QString szPrefixPath = szFileName.left(idx);
		if(!KviFileUtils::makeDir(szPrefixPath))
		{
			setLastError(__tr2qs("Failed to create the target directory"));
			return false;
		}
	}

	KviFile dest(szFileName);
	if(!dest.open(QFile::WriteOnly | QFile::Truncate))
	{
		setLastError(__tr2qs("Failed to open a source file for reading"));
		return false;
	}

	QString szProgressText = QString(__tr2qs("Unpacking file %1")).arg(szFileName);
	if(!updateProgress(pFile->pos(), szProgressText))
		return false; // aborted

	// Size
	kvi_u32_t uSize;
	if(!pFile->load(uSize))
		return readError();

// FilePayload
#ifdef COMPILE_ZLIB_SUPPORT
	if(uFlags & KVI_PACKAGE_DATAFIELD_FLAG_FILE_DEFLATE)
	{
		//qDebug ("loading compressed data");
		int iRemainingSize = uSize;
		unsigned char ibuffer[BUFFER_SIZE];
		unsigned char obuffer[BUFFER_SIZE];

		int iToRead = iRemainingSize;
		if(iToRead > BUFFER_SIZE)
			iToRead = BUFFER_SIZE;
		int iReaded = pFile->read((char *)ibuffer, iToRead);
		iRemainingSize -= iReaded;

		z_stream zstr;
		zstr.zalloc = Z_NULL;
		zstr.zfree = Z_NULL;
		zstr.opaque = Z_NULL;
		zstr.next_in = ibuffer;
		zstr.avail_in = iReaded;
		zstr.next_out = obuffer;
		zstr.avail_out = BUFFER_SIZE;

		if(inflateInit(&zstr) != Z_OK)
		{
			setLastError(__tr2qs("Compression library initialization error"));
			return false;
		}

		while((iReaded > 0) && (iRemainingSize > 0))
		{
			zstr.next_out = obuffer;
			zstr.avail_out = BUFFER_SIZE;

			if(inflate(&zstr, Z_NO_FLUSH) != Z_OK)
			{
				setLastError(__tr2qs("Compression library error"));
				return false;
			}

			if(zstr.avail_out < BUFFER_SIZE)
			{
				int iDecompressed = zstr.next_out - obuffer;
				if(dest.write((char *)obuffer, iDecompressed) != iDecompressed)
				{
					inflateEnd(&zstr);
					return writeError();
				}
			}

			if(zstr.avail_in < BUFFER_SIZE)
			{
				int iDataToRead = BUFFER_SIZE - zstr.avail_in;
				if(iDataToRead < BUFFER_SIZE)
				{
					if(ibuffer != zstr.next_in)
					{
						// hum, there is still some data in the buffer to be readed
						// and it is not at the beginning...move it to the beginning of ibuffer
						memmove(ibuffer, zstr.next_in, zstr.avail_in);
					}
				}

				if(iDataToRead > iRemainingSize)
					iDataToRead = iRemainingSize;

				iReaded = pFile->read((char *)(ibuffer + zstr.avail_in), iDataToRead);
				if(iReaded < 0)
				{
					inflateEnd(&zstr);
					return readError();
				}

				iRemainingSize -= iReaded;
				zstr.avail_in += iReaded;
				zstr.next_in = ibuffer;

				if((zstr.total_in % 2000000) == 0)
				{
					QString szTmp = QString(" (%1 of %2 bytes)").arg(zstr.total_in, uSize);
					QString szPrg = szProgressText + szTmp;
					if(!updateProgress(pFile->pos(), szPrg))
						return false; // aborted
				}
			}
		}
		// flush pending output
		zstr.next_out = obuffer;
		zstr.avail_out = BUFFER_SIZE;

		int ret;

		do
		{
			ret = inflate(&zstr, Z_FINISH);

			if((ret == Z_OK) || (ret == Z_STREAM_END) || (ret == Z_BUF_ERROR))
			{
				if(zstr.avail_out < BUFFER_SIZE)
				{
					int iDecompressed = zstr.next_out - obuffer;
					if(dest.write((char *)obuffer, iDecompressed) != iDecompressed)
					{
						inflateEnd(&zstr);
						return writeError();
					}
				}
				else
				{
					//THIS HAPPENS FOR ZERO SIZE FILES
					qDebug("Hum... internal, rEWq (ret = %d) (avail_out = %d)", ret, zstr.avail_out);

					inflateEnd(&zstr);
					setLastError(__tr2qs("Compression library internal error"));
					return false;
				}
				zstr.next_out = obuffer;
				zstr.avail_out = BUFFER_SIZE;
			}

		} while((ret == Z_OK) || (ret == Z_BUF_ERROR));

		inflateEnd(&zstr);

		if(ret != Z_STREAM_END)
		{
			setLastError(__tr2qs("Error in compressed file stream"));
			return false;
		}
	}
	else
	{
#endif
		//qDebug("Load uncompressed data");
		unsigned char buffer[BUFFER_SIZE];
		int iTotalFileSize = 0;
		int iRemainingData = uSize;
		int iToRead = iRemainingData;
		if(iToRead > BUFFER_SIZE)
			iToRead = BUFFER_SIZE;
		int iReaded = 1;
		//qDebug("iReaded %i and iToRead %i and index %i",iReaded,iToRead,pFile->pos());
		while((iReaded > 0) && (iToRead > 0))
		{
			iReaded = pFile->read((char *)buffer, iToRead);
			if(iReaded > 0)
			{
				iTotalFileSize += iReaded;
				iRemainingData -= iReaded;

				if((iTotalFileSize % 3000000) == 0)
				{
					QString szTmp = QString(" (%1 of %2 bytes)").arg(iTotalFileSize).arg(uSize);
					QString szPrg = szProgressText + szTmp;
					if(!updateProgress(pFile->pos(), szPrg))
						return false; // aborted
				}
				//qDebug("write file with size %i and name %s",iReaded,dest.fileName().toUtf8().data());
				if(dest.write((char *)buffer, iReaded) != iReaded)
					return writeError();
			}
			//qDebug("Remains %i", iRemainingData);
			iToRead = iRemainingData;
			if(iToRead > BUFFER_SIZE)
				iToRead = BUFFER_SIZE;
		}
//qDebug("finish to read %i and index %i",iReaded,pFile->pos());
#ifdef COMPILE_ZLIB_SUPPORT
	}
#endif
	dest.close();

	return true;
}
Exemple #20
0
void KviWindow::createTextEncodingButton(QWidget * pPar)
{
	delete m_pTextEncodingButton;
	m_pTextEncodingButton = createToolButton(pPar, "text_encoding_button", KviIconManager::TextEncoding, __tr2qs("Text encoding"), false);
	connect(m_pTextEncodingButton, SIGNAL(clicked()), this, SLOT(textEncodingButtonClicked()));
}
Exemple #21
0
void register_core_actions(KviActionManager * m)
{
	m->registerAction(new KviConnectAction(m)); // this as parent will destroy it on exit!
	m->registerAction(new KviSeparatorAction(m));
	m->registerAction(new KviIrcContextDisplayAction(m));
	m->registerAction(new KviJoinChannelAction(m));
	m->registerAction(new KviChangeNickAction(m));
	m->registerAction(new KviConnectToServerAction(m));
	m->registerAction(new KviChangeUserModeAction(m));
	m->registerAction(new KviGoAwayAction(m));
	m->registerAction(new KviIrcToolsAction(m));
	m->registerAction(new KviIrcOperationsAction(m));

	KviAction * a;

#define SCRIPT_ACTION(__name,__code,__visible,__description,__category,__icon,__smallicon,__flags,__accel) \
	a = new KviKvsAction(m, \
		QString(__name), \
		QString(__code), \
		QString(__visible), \
		QString(__description), \
		__category, \
		QString(__icon), \
		__smallicon, \
		__flags, \
		QKeySequence(__accel).toString()); \
	m->registerAction(a)

#define SLOT_ACTION(__name,__object,__slot,__visible,__description,__category,__icon,__smallicon,__flags,__accel) \
	a = new KviAction(m, \
		QString(__name), \
		QString(__visible), \
		QString(__description), \
		__category, \
		QString(__icon), \
		__smallicon, \
		__flags, \
		QKeySequence(__accel).toString()); \
	QObject::connect(a,SIGNAL(activated()),__object,__slot); \
	m->registerAction(a)

	SCRIPT_ACTION(
		KVI_COREACTION_SERVEROPTIONS,
		"options.edit -t OptionsWidget_servers",
		__tr2qs("Configure Servers..."),
		__tr2qs("Allows you to configure the servers and eventually to connect to them"),
		KviActionManager::categorySettings(),
		"kvi_bigicon_servers.png",
		KviIconManager::Server,
		0,
		KVI_SHORTCUTS_SERVERS);

	SCRIPT_ACTION(
		KVI_COREACTION_MANAGEADDONS,
		"addon.dialog -t",
		__tr2qs("Manage Addons..."),
		__tr2qs("Allows you to manage the script-based addons"),
		KviActionManager::categorySettings(),
		"kvi_bigicon_addons.png",
		KviIconManager::Addons,
		0,
		KVI_SHORTCUTS_MANAGE_ADDONS);

	SCRIPT_ACTION(
		KVI_COREACTION_EDITREGUSERS,
		"reguser.edit -t",
		__tr2qs("Configure Registered Users..."),
		__tr2qs("Shows a dialog that allows editing the registered user entries"),
		KviActionManager::categorySettings(),
		"kvi_bigicon_regusers.png",
		KviIconManager::RegUsers,
		0,
		KVI_SHORTCUTS_USERS);

	SCRIPT_ACTION(
		KVI_COREACTION_IDENTITYOPTIONS,
		"options.edit -t OptionsWidget_identity",
		__tr2qs("Configure Identity..."),
		__tr2qs("Allows you to configure nickname, username, avatar etc..."),
		KviActionManager::categorySettings(),
		"kvi_bigicon_identity.png",
		KviIconManager::Identity,
		0,
		KVI_SHORTCUTS_IDENTITY);

	SCRIPT_ACTION(
		KVI_COREACTION_SOCKETSPY,
		"socketspy.open",
		__tr2qs("Show SocketSpy"),
		__tr2qs("Shows a window that allows monitoring the socket traffic"),
		KviActionManager::categoryScripting(),
		"kvi_bigicon_socketspy.png",
		KviIconManager::Spy,
		KviAction::NeedsContext,
		QString());

	SCRIPT_ACTION(
		KVI_COREACTION_NETWORKLINKS,
		"links.open",
		__tr2qs("Get Network Links"),
		__tr2qs("Shows a window that allows viewing the network links"),
		KviActionManager::categoryIrc(),
		"kvi_bigicon_links.png",
		KviIconManager::Links,
		KviAction::NeedsContext,
		QString());

	SCRIPT_ACTION(
		KVI_COREACTION_CHANNELLIST,
		"list.open",
		__tr2qs("Get Channel List"),
		__tr2qs("Shows a window that allows listing the network channels"),
		KviActionManager::categoryIrc(),
		"kvi_bigicon_channellist.png",
		KviIconManager::List,
		KviAction::NeedsContext,
		QString());

	SCRIPT_ACTION(
		KVI_COREACTION_GENERALOPTIONS,
		"options.dialog -t",
		__tr2qs("Configure KVIrc..."),
		__tr2qs("Shows the general options dialog"),
		KviActionManager::categorySettings(),
		"kvi_bigicon_settings.png",
		KviIconManager::Options,
		0,
		KVI_SHORTCUTS_OPTIONS);

	SCRIPT_ACTION(
		KVI_COREACTION_THEMEOPTIONS,
		"options.dialog -t theme",
		__tr2qs("Configure Theme..."),
		__tr2qs("Shows the theme options dialog"),
		KviActionManager::categorySettings(),
		"kvi_bigicon_themeoptions.png",
		KviIconManager::ThemeOptions,
		0,
		KVI_SHORTCUTS_THEME);

	SCRIPT_ACTION(
		KVI_COREACTION_MANAGETHEMES,
		"theme.dialog -t",
		__tr2qs("Manage Themes..."),
		__tr2qs("Allows you to manage the themes"),
		KviActionManager::categorySettings(),
		"kvi_bigicon_theme.png",
		KviIconManager::Theme,
		0,
		KVI_SHORTCUTS_MANAGE_THEMES);

	SCRIPT_ACTION(
		KVI_COREACTION_TOOLBAREDITOR,
		"toolbareditor.open -t",
		__tr2qs("Customize Toolbars..."),
		__tr2qs("Shows a window that allows editing script toolbars"),
		KviActionManager::categorySettings(),
		"kvi_bigicon_toolbareditor.png",
		KviIconManager::ToolBar,
		0,
		KVI_SHORTCUTS_EDITORS_TOOLBAR);

	SCRIPT_ACTION(
		KVI_COREACTION_JOINCHANNELS,
		"channelsjoin.open",
		__tr2qs("Join Channels..."),
		__tr2qs("Shows a dialog that allows you join channels"),
		KviActionManager::categoryIrc(),
		"kvi_bigicon_channels.png",
		KviIconManager::Channel,
		KviKvsAction::NeedsConnection | KviKvsAction::NeedsContext,
		KVI_SHORTCUTS_JOIN);

	SCRIPT_ACTION(
		KVI_COREACTION_ACTIONEDITOR,
		"actioneditor.open",
		__tr2qs("Edit Actions..."),
		__tr2qs("Shows a window that allows editing actions"),
		KviActionManager::categoryScripting(),
		"kvi_bigicon_actioneditor.png",
		KviIconManager::ActionEditor,
		0,
		KVI_SHORTCUTS_EDITORS_ACTION);

	SCRIPT_ACTION(
		KVI_COREACTION_ALIASEDITOR,
		"aliaseditor.open",
		__tr2qs("Edit Aliases..."),
		__tr2qs("Shows a window that allows editing aliases"),
		KviActionManager::categoryScripting(),
		"kvi_bigicon_aliaseditor.png",
		KviIconManager::AliasEditor,
		0,
		KVI_SHORTCUTS_EDITORS_ALIAS);

	SCRIPT_ACTION(
		KVI_COREACTION_CLASSEDITOR,
		"classeditor.open",
		__tr2qs("Edit Classes..."),
		__tr2qs("Shows a window that allows editing classes"),
		KviActionManager::categoryScripting(),
		"kvi_bigicon_classeditor.png",
		KviIconManager::ClassEditor,
		0,
		KVI_SHORTCUTS_EDITORS_CLASS);

	SCRIPT_ACTION(
		KVI_COREACTION_EVENTEDITOR,
		"eventeditor.open",
		__tr2qs("Edit Events..."),
		__tr2qs("Shows a window that allows editing script events"),
		KviActionManager::categoryScripting(),
		"kvi_bigicon_eventeditor.png",
		KviIconManager::EventEditor,
		0,
		KVI_SHORTCUTS_EDITORS_EVENT);

	SCRIPT_ACTION(
		KVI_COREACTION_POPUPEDITOR,
		"popupeditor.open",
		__tr2qs("Edit Popups..."),
		__tr2qs("Shows a window that allows editing popup menus"),
		KviActionManager::categoryScripting(),
		"kvi_bigicon_popupeditor.png",
		KviIconManager::PopupEditor,
		0,
		KVI_SHORTCUTS_EDITORS_POPUP);

	SCRIPT_ACTION(
		KVI_COREACTION_RAWEDITOR,
		"raweditor.open",
		__tr2qs("Edit Raw Events..."),
		__tr2qs("Shows a window that allows editing raw scripting events"),
		KviActionManager::categoryScripting(),
		"kvi_bigicon_raweditor.png",
		KviIconManager::RawEventEditor,
		0,
		KVI_SHORTCUTS_EDITORS_RAW);

	SCRIPT_ACTION(
		KVI_COREACTION_CODETESTER,
		"codetester.open",
		__tr2qs("Script Tester"),
		__tr2qs("Creates an embedded editor for long scripts"),
		KviActionManager::categoryScripting(),
		"kvi_bigicon_codetester.png",
		KviIconManager::Bomb,
		0,
		KVI_SHORTCUTS_EDITORS_TESTER);

	SCRIPT_ACTION(
		KVI_COREACTION_EXECUTEKVS,
		"dialog.file(open,$tr(\"Select a Script File\")){ if(!$str.isEmpty($0))parse $0; }",
		__tr2qs("Execute Script..."),
		__tr2qs("Allows executing a KVS script from file"),
		KviActionManager::categoryScripting(),
		"kvi_bigicon_folder.png",
		KviIconManager::Folder,
		0,
		KVI_SHORTCUTS_EXEC);

	SCRIPT_ACTION(
		KVI_COREACTION_HELPINDEX,
		"help -m",
		__tr2qs("Help Index"),
		__tr2qs("Shows the documentation index"),
		KviActionManager::categoryGeneric(),
		"kvi_bigicon_help.png",
		KviIconManager::Help,
		0,
		KVI_SHORTCUTS_HELP);

	SCRIPT_ACTION(
		KVI_COREACTION_KVIRCMAILINGLIST,
		"openurl http://www.kvirc.net/?id=mailinglist",
		__tr2qs("Subscribe to the Mailing List"),
		__tr2qs("Allows subscribing to the KVIrc mailing list"),
		KviActionManager::categoryGeneric(),
		"kvi_bigicon_mailinglist.png",
		KviIconManager::Message,
		0,
		QString());

	SCRIPT_ACTION(
		KVI_COREACTION_KVIRCHOMEPAGE,
		"openurl http://www.kvirc.net",
		__tr2qs("KVIrc WWW"),
		__tr2qs("Opens the KVIrc homepage"),
		KviActionManager::categoryGeneric(),
		"kvi_bigicon_homepage.png",
		KviIconManager::HomePage,
		0,
		QString());

	SCRIPT_ACTION(
		KVI_COREACTION_KVIRCRUHOMEPAGE,
		"openurl http://www.kvirc.ru",
		__tr2qs("KVIrc Russian WWW"),
		__tr2qs("Opens the KVIrc homepage in russian"),
		KviActionManager::categoryGeneric(),
		"kvi_bigicon_homepage.png",
		KviIconManager::HomePage,
		0,
		QString());

	SCRIPT_ACTION(
		KVI_COREACTION_SCREENSHOT,
		"theme.screenshot",
		__tr2qs("Acquire Screenshot"),
		__tr2qs("Acquires a Screenshot of the KVIrc main window"),
		KviActionManager::categoryGeneric(),
		"kvi_bigicon_screenshot.png",
		KviIconManager::ScreenShot,
		0,
		QString());

	SCRIPT_ACTION(
		KVI_COREACTION_FILETRANSFER,
		"filetransferwindow.open",
		__tr2qs("Manage File &Transfers"),
		__tr2qs("Shows a window that lists file transfers"),
		KviActionManager::categoryGeneric(),
		"kvi_bigicon_filetransfer.png",
		KviIconManager::FileTransfer,
		0,
		QString());

	SCRIPT_ACTION(
		KVI_COREACTION_IOGRAPH,
		"iograph.open",
		__tr2qs("Show I/O &Traffic graph"),
		__tr2qs("Shows a graph representing I/O bandwidth traffic"),
		KviActionManager::categoryGeneric(),
		"kvi_bigicon_sysmonitor.png",
		KviIconManager::SysMonitor,
		0,
		QString());

	SCRIPT_ACTION(
		KVI_COREACTION_LOGVIEWER,
		"logview.open",
		__tr2qs("Browse Log Files"),
		__tr2qs("Shows a window that lists and filter log files"),
		KviActionManager::categoryGeneric(),
		"kvi_bigicon_log.png",
		KviIconManager::Log,
		0,
		QString());

	SCRIPT_ACTION(
		KVI_COREACTION_SHAREDFILES,
		"sharedfileswindow.open",
		__tr2qs("Manage S&hared Files"),
		__tr2qs("Shows a window that list shared files"),
		KviActionManager::categoryGeneric(),
		"kvi_bigicon_sharedfiles.png",
		KviIconManager::SharedFiles,
		0,
		QString());

	SCRIPT_ACTION(
		KVI_COREACTION_URLLIST,
		"url.list",
		__tr2qs("View URL list"),
		__tr2qs("Shows a window that list catched urls"),
		KviActionManager::categoryGeneric(),
		"kvi_bigicon_url.png",
		KviIconManager::Url,
		0,
		QString());

	SLOT_ACTION(
		KVI_COREACTION_NEWIRCCONTEXT,
		g_pMainWindow,
		SLOT(newConsole()),
		__tr2qs("New IRC Context"),
		__tr2qs("Creates a new IRC context console"),
		KviActionManager::categoryIrc(),
		"kvi_bigicon_newitem.png",
		KviIconManager::NewItem,
		0,
		KVI_SHORTCUTS_CONTEXT);

	SLOT_ACTION(
		KVI_COREACTION_QUITKVIRC,
		g_pApp,
		SLOT(quit()),
		__tr2qs("Quit KVIrc"),
		__tr2qs("Quits KVIrc closing all the current connections"),
		KviActionManager::categoryGeneric(),
		"kvi_bigicon_quitapp.png",
		KviIconManager::QuitApp,
		0,
		QString());
}
Exemple #22
0
void KviWindow::listWindowTypes()
{
	outputNoFmt(KVI_OUT_SYSTEMMESSAGE, __tr2qs("List of window types available in this release of KVIrc:"));
	for(auto & i : m_typeTable)
		outputNoFmt(KVI_OUT_SYSTEMMESSAGE, i);
}
Exemple #23
0
bool KviWatchNotifyListManager::handleWatchReply(KviIrcMessage * msg)
{
	// 600: RPL_LOGON
	// :prefix 600 <target> <nick> <user> <host> <logintime> :logged online
	// 601: RPL_LOGOFF
	// :prefix 601 <target> <nick> <user> <host> <logintime> :logged offline
	// 604: RPL_NOWON
	// :prefix 604 <target> <nick> <user> <host> <logintime> :is online
	// 605: RPL_NOWOFF
	// :prefix 605 <target> <nick> <user> <host> 0 :is offline

	// FIXME: #warning "Use the logintime in some way ?"

	const char * nk = msg->safeParam(1);
	const char * us = msg->safeParam(2);
	const char * ho = msg->safeParam(3);
	QString dnk = m_pConnection->decodeText(nk);
	QString dus = m_pConnection->decodeText(us);
	QString dho = m_pConnection->decodeText(ho);

	if((msg->numeric() == RPL_LOGON) || (msg->numeric() == RPL_NOWON))
	{
		KviIrcMask m(dnk, dus, dho);
		doMatchUser(msg, dnk, m);
		return true;
	}
	else if(msg->numeric() == RPL_WATCHOFF)
	{
		if(m_pConsole->notifyListView()->findEntry(dnk))
		{
			notifyOffLine(dnk, dus, dho, __tr2qs("removed from watch list"));
		}
		else
		{
			if(_OUTPUT_VERBOSE)
				m_pConsole->output(KVI_OUT_SYSTEMMESSAGE, __tr2qs("Notify list: Stopped watching for \r!n\r%Q\r"), &dnk);
		}
		if(m_pRegUserDict.count(dnk))
			m_pRegUserDict.erase(dnk); // kill that

		return true;
	}
	else if((msg->numeric() == RPL_LOGOFF) || (msg->numeric() == RPL_NOWOFF))
	{
		if(m_pConsole->notifyListView()->findEntry(dnk))
		{
			notifyOffLine(dnk, dus, dho, __tr2qs("watch"));
		}
		else
		{
			if(msg->numeric() == RPL_NOWOFF)
			{
				// This is a reply to a /watch +something
				if(_OUTPUT_VERBOSE)
					m_pConsole->output(KVI_OUT_SYSTEMMESSAGE, __tr2qs("Notify list: \r!n\r%Q\r is offline (watch)"), &dnk);
			}
			else
			{
				// This is a RPL_LOGOFF for a user that has not matched the reg-mask
				notifyOffLine(dnk, dus, dho, __tr2qs("unmatched watch list entry"));
			}
		}
		return true;
	}

	return false;
}
Exemple #24
0
void KviWindow::createSystemTextEncodingPopup()
{
	if(!g_pMdiWindowSystemTextEncodingPopup)
	{
		// first time called, create the menu
		g_pMdiWindowSystemTextEncodingPopup = new QMenu();
		g_pMdiWindowSystemTextEncodingPopupStandard = new QMenu();
		g_pMdiWindowSystemTextEncodingPopupSmart = new QMenu();
		g_pMdiWindowSystemTextEncodingPopupSmartUtf8 = new QMenu();
		g_pMdiWindowSystemTextEncodingActionGroup = new QActionGroup(g_pMdiWindowSystemTextEncodingPopup);

		//default action
		QTextCodec * pCodec = defaultTextCodec();
		QString szTmp = __tr2qs("Use Default Encoding");
		if(pCodec)
		{
			szTmp += " (";
			szTmp += pCodec->name();
			szTmp += ")";
		}

		g_pMdiWindowSystemTextEncodingDefaultAction = g_pMdiWindowSystemTextEncodingPopup->addAction(szTmp);
		g_pMdiWindowSystemTextEncodingActionGroup->addAction(g_pMdiWindowSystemTextEncodingDefaultAction);
		g_pMdiWindowSystemTextEncodingDefaultAction->setData(-1);
		if(m_szTextEncoding.isEmpty())
		{
			g_pMdiWindowSystemTextEncodingDefaultAction->setCheckable(true);
			g_pMdiWindowSystemTextEncodingDefaultAction->setChecked(true);
		}

		//current action
		g_pMdiWindowSystemTextEncodingCurrentAction = g_pMdiWindowSystemTextEncodingPopup->addAction(__tr2qs("Current: "));
		g_pMdiWindowSystemTextEncodingActionGroup->addAction(g_pMdiWindowSystemTextEncodingCurrentAction);
		g_pMdiWindowSystemTextEncodingCurrentAction->setVisible(false);

		// other first level menus
		g_pMdiWindowSystemTextEncodingPopup->addSeparator();

		QAction * pAction = g_pMdiWindowSystemTextEncodingPopup->addAction(__tr2qs("Standard"));
		pAction->setMenu(g_pMdiWindowSystemTextEncodingPopupStandard);
		pAction = g_pMdiWindowSystemTextEncodingPopup->addAction(__tr2qs("Smart (Send Local)"));
		pAction->setMenu(g_pMdiWindowSystemTextEncodingPopupSmart);
		pAction = g_pMdiWindowSystemTextEncodingPopup->addAction(__tr2qs("Smart (Send UTF-8)"));
		pAction->setMenu(g_pMdiWindowSystemTextEncodingPopupSmartUtf8);

		// second level menus (encoding groups)
		QMenu * pPopupStandard[KVI_NUM_ENCODING_GROUPS];
		QMenu * pPopupSmart[KVI_NUM_ENCODING_GROUPS];
		QMenu * pPopupSmartUtf8[KVI_NUM_ENCODING_GROUPS];

		uint u = 0;
		const char * pcEncodingGroup = KviLocale::instance()->encodingGroup(u);

		while(pcEncodingGroup)
		{
			pPopupStandard[u] = g_pMdiWindowSystemTextEncodingPopupStandard->addMenu(pcEncodingGroup);
			if(u) //only standard popup contains unicode menu
			{
				pPopupSmart[u] = g_pMdiWindowSystemTextEncodingPopupSmart->addMenu(pcEncodingGroup);
				pPopupSmartUtf8[u] = g_pMdiWindowSystemTextEncodingPopupSmartUtf8->addMenu(pcEncodingGroup);
			}

			pcEncodingGroup = KviLocale::instance()->encodingGroup(++u);
		}

		// third level menus (encodings)
		uint i = 0;
		KviLocale::EncodingDescription * pDesc = KviLocale::instance()->encodingDescription(i);
		while(pDesc->pcName)
		{
			szTmp = QString("%1 (%2)").arg(pDesc->pcName, pDesc->pcDescription);
			if(KviQString::equalCI(m_szTextEncoding, pDesc->pcName))
			{
				g_pMdiWindowSystemTextEncodingCurrentAction->setText(__tr2qs("Current: ") + szTmp);
				g_pMdiWindowSystemTextEncodingCurrentAction->setCheckable(true);
				g_pMdiWindowSystemTextEncodingCurrentAction->setChecked(true);
				g_pMdiWindowSystemTextEncodingCurrentAction->setVisible(true);
				g_pMdiWindowSystemTextEncodingCurrentAction->setData(i);
			}

			QMenu * pMenu = pDesc->bSmart ? (pDesc->bSendUtf8 ? pPopupSmartUtf8[pDesc->uGroup] : pPopupSmart[pDesc->uGroup]) : pPopupStandard[pDesc->uGroup];

			QAction * pAction = pMenu->addAction(szTmp);
			pAction->setData(i);
			g_pMdiWindowSystemTextEncodingActionGroup->addAction(pAction);

			pDesc = KviLocale::instance()->encodingDescription(++i);
		}
	}
	else
	{
		//default action: refresh the name
		QTextCodec * pCodec = defaultTextCodec();
		QString szTmp = __tr2qs("Use Default Encoding");
		if(pCodec)
		{
			szTmp += " (";
			szTmp += pCodec->name();
			szTmp += ")";
		}

		disconnect(g_pMdiWindowSystemTextEncodingActionGroup, SIGNAL(triggered(QAction *)), nullptr, nullptr);
		connect(g_pMdiWindowSystemTextEncodingActionGroup, SIGNAL(triggered(QAction *)), this, SLOT(systemTextEncodingPopupActivated(QAction *)));
		g_pMdiWindowSystemTextEncodingDefaultAction->setText(szTmp);

		//menu already exists, choose the right item
		if(m_szTextEncoding.isEmpty())
		{
			//default action; hide the current action
			g_pMdiWindowSystemTextEncodingCurrentAction->setVisible(false);
			g_pMdiWindowSystemTextEncodingDefaultAction->setCheckable(true);
			g_pMdiWindowSystemTextEncodingDefaultAction->setChecked(true);
		}
		else
		{
			int i = 0;
			KviLocale::EncodingDescription * pDesc = KviLocale::instance()->encodingDescription(i);
			while(pDesc->pcName)
			{
				if(KviQString::equalCI(m_szTextEncoding, pDesc->pcName))
				{
					szTmp = QString("%1 (%2)").arg(pDesc->pcName, pDesc->pcDescription);
					g_pMdiWindowSystemTextEncodingCurrentAction->setText(__tr2qs("Current: ") + szTmp);
					g_pMdiWindowSystemTextEncodingCurrentAction->setCheckable(true);
					g_pMdiWindowSystemTextEncodingCurrentAction->setChecked(true);
					g_pMdiWindowSystemTextEncodingCurrentAction->setVisible(true);
					g_pMdiWindowSystemTextEncodingCurrentAction->setData(i);
					break;
				}

				pDesc = KviLocale::instance()->encodingDescription(++i);
			}
		}
	}

	disconnect(g_pMdiWindowSystemTextEncodingActionGroup, SIGNAL(triggered(QAction *)), nullptr, nullptr);
	connect(g_pMdiWindowSystemTextEncodingActionGroup, SIGNAL(triggered(QAction *)), this, SLOT(systemTextEncodingPopupActivated(QAction *)));
}
Exemple #25
0
bool KviIsOnNotifyListManager::handleIsOn(KviIrcMessage * msg)
{
	if(!m_bExpectingIsOn)
		return false;

	// Check if it is our ISON
	// all the nicks must be on the IsOnList

	std::set<std::size_t> tmplist;

	KviCString nk;
	const char * aux = msg->trailing();

	while(*aux)
	{
		nk = "";
		aux = kvi_extractToken(nk, aux, ' ');
		if(nk.hasData())
		{
			bool bGotIt = false;
			QString dnk = m_pConnection->decodeText(nk.ptr());

			std::size_t i = 0;
			for(const auto & s : m_IsOnList)
			{
				if(KviQString::equalCI(s, dnk))
				{
					tmplist.insert(i);
					bGotIt = true;
					break;
				}
				i++;
			}
			if(!bGotIt)
			{
				// oops... not my userhost!
				if(_OUTPUT_VERBOSE)
					m_pConsole->output(KVI_OUT_SYSTEMMESSAGE, __tr2qs("Notify list: Hey! You've used ISON behind my back? (I might be confused now...)"));
				return false;
			}
		}
	}

	// Ok... looks to be my ison (still not sure at 100%, but can't do better)
	if(m_pConnection->lagMeter())
		m_pConnection->lagMeter()->lagCheckComplete("@notify_ison");

	m_bExpectingIsOn = false;

	m_OnlineList.clear();

	// Ok... we have an IsOn reply here
	// The nicks in the IsOnList that are also in the reply are online, and go to the OnlineList
	// the remaining in the IsOnList are offline
	for(auto i = tmplist.rbegin(); i != tmplist.rend(); ++i)
	{
		m_OnlineList.push_back(std::move(m_IsOnList[*i]));
		m_IsOnList.erase(m_IsOnList.begin() + *i);
	}

	// Ok... all the users that are online, are on the OnlineList
	// the remaining users are in the m_IsOnList, and are no longer online

	// first the easy step: remove the users that have just left irc or have never been online
	// we're clearling the m_IsOnList
	for(const auto & s : m_IsOnList)
	{
		// has just left IRC... make him part
		if(m_pConsole->notifyListView()->findEntry(s))
			notifyOffLine(s);
	}

	m_IsOnList.clear();

	// ok... complex step now: the remaining users in the userhost list are online
	// if they have been online before, just remove them from the list
	// otherwise they must be matched for masks
	// and eventually inserted in the notify view later

	KviIrcUserDataBase * db = console()->connection()->userDataBase();

	std::set<std::size_t> l;
	std::size_t i = 0;
	for(const auto & ss : m_OnlineList)
	{
		if(KviUserListEntry * ent = m_pConsole->notifyListView()->findEntry(ss))
		{
			// the user was online from a previous notify session
			// might the mask have been changed ? (heh... this is tricky, maybe too much even)
			if(KVI_OPTION_BOOL(KviOption_boolNotifyListSendUserhostForOnlineUsers))
			{
				// user wants to be sure about online users....
				// check if he is on some channels
				if(ent->globalData()->nRefs() > 1)
				{
					// mmmh... we have more than one ref, so the user is at least in one query or channel
					// look him up on channels, if we find his entry, we can be sure that he is
					// still the right user
					std::vector<KviChannelWindow *> chlist = m_pConsole->connection()->channelList();
					for(auto ch : chlist)
					{
						if(KviUserListEntry * le = ch->findEntry(ss))
						{
							l.insert(i); // ok... found on a channel... we don't need a userhost to match him
							KviIrcMask mk(ss, le->globalData()->user(), le->globalData()->host());
							if(!doMatchUser(ss, mk))
								return true; // critical problems = have to restart!!!
							break;
						}
					}
				} // else Only one ref... we need a userhost to be sure (don't remove from the list)
			}
			else
			{
				// user wants no userhost for online users... we "hope" that everything will go ok.
				l.insert(i);
			}
			//l.insert(i); // we will remove him from the list
		}
		else
		{
			// the user was not online!
			// check if we have a cached mask
			if(db)
			{
				if(KviIrcUserEntry * ue = db->find(ss))
				{
					// already in the db... do we have a mask ?
					if(ue->hasUser() && ue->hasHost())
					{
						// yup! we have a complete mask to match on
						KviIrcMask mk(ss, ue->user(), ue->host());
						// lookup the user's name in the m_pRegUserDict
						if(!doMatchUser(ss, mk))
							return true; // critical problems = have to restart!!!
						l.insert(i);     // remove anyway
					}
				}
			}
		}

		i++;
	}

	for(auto i = l.rbegin(); i != l.rend(); ++i)
	{
		m_OnlineList.erase(m_OnlineList.begin() + *i);
	}

	if(m_OnlineList.empty())
	{
		if(m_NotifyList.empty())
			delayedNotifySession();
		else
			delayedIsOnSession();
	}
	else
		delayedUserhostSession();

	return true;
}
bool KviPackageIOEngine::writeError()
{
	setLastError(__tr2qs("File write error"));
	return false;
}
//mouse events
void KviIrcView::mouseDoubleClickEvent(QMouseEvent *e)
{
	QString szKvsCommand;
	QString szLinkCommandPart;
	QString szLinkTextPart;

	if(m_iMouseTimer)
	{
		killTimer(m_iMouseTimer);
		m_iMouseTimer=0;
		delete m_pLastEvent;
		m_pLastEvent = 0;
	}

	getLinkUnderMouse(e->pos().x(),e->pos().y(),0,&szLinkCommandPart,&szLinkTextPart);

	if(szLinkCommandPart.isEmpty())
	{
		KVS_TRIGGER_EVENT_0(KviEvent_OnTextViewDoubleClicked,m_pKviWindow);
		return;
	}

	KviKvsVariantList lParams;
	lParams.append(szLinkTextPart);

	switch(szLinkCommandPart[0].unicode())
	{
		case 'n':
		{
			switch(m_pKviWindow->type())
			{
				case KviWindow::Channel:
					if(((KviChannelWindow *)m_pKviWindow)->isOn(szLinkTextPart))
					{
						KVS_TRIGGER_EVENT(KviEvent_OnChannelNickDefaultActionRequest,m_pKviWindow,&lParams);
						return;
					}
				break;
				case KviWindow::Query:
					if(KviQString::equalCI(((KviQueryWindow *)m_pKviWindow)->windowName(),szLinkTextPart))
					{
						KVS_TRIGGER_EVENT(KviEvent_OnQueryNickDefaultActionRequest,m_pKviWindow,&lParams);
						return;
					}
				break;
				default:
					return; // unhandled window type (FIXME: Let it go anyway ?)
				break;
			}
			if(console())
				KVS_TRIGGER_EVENT(KviEvent_OnNickLinkDefaultActionRequest,m_pKviWindow,&lParams);
			return;
		}
		break;
		case 'm': // m+X[ param] / m-X[ param] (used to quickly undo mode changes)
		{
			// Syntax is
			//   m<plus_or_minus><mode_char>[ <parameter>]

			if(szLinkCommandPart.length() < 3)
				return; // malformed
			if(m_pKviWindow->type() != KviWindow::Channel)
				return; // must be on a channel to apply it
			if(!(((KviChannelWindow *)m_pKviWindow)->isMeOp()))
				return; // i'm not op, can't do mode changes

			QString szPart = szLinkCommandPart.mid(1);

			szKvsCommand = QString("mode $chan.name %1").arg(szPart);
		}
		break;
		case 'h':
			m_pKviWindow->output(KVI_OUT_HOSTLOOKUP,__tr2qs("Looking up host %Q..."),&szLinkTextPart);
			szKvsCommand = "host -a $0";
		break;
		case 'u':
			if(KVI_OPTION_UINT(KviOption_uintUrlMouseClickNum) == 2) // <-- ??????????
			{
				KVS_TRIGGER_EVENT(KviEvent_OnURLLinkClick,m_pKviWindow,&lParams);
				return;
			}
		break;
		case 'c':
		{
			if(!console())
				return;
			if(!console()->connection())
				return;

			// If there is a channel after the c flag, join that instead (as the text part may contain control codes)
			if(szLinkCommandPart.length() > 1)
				szLinkTextPart = szLinkCommandPart.mid(1);

			if(KviChannelWindow * c = console()->connection()->findChannel(szLinkTextPart))
			{
				// already there
				g_pMainWindow->setActiveWindow(c);
				return;
			}

			szKvsCommand = "join $0";
		}
		break;
		case 's':
			szKvsCommand = "motd $0";
		break;
		default:
		{
			// extract the user-supplied double click command
			getLinkEscapeCommand(szKvsCommand,szLinkCommandPart,"[!dbl]");
			if(szKvsCommand.isEmpty())
			{
				KVS_TRIGGER_EVENT_0(KviEvent_OnTextViewDoubleClicked,m_pKviWindow);
				return;
			}
		}
		break;
	}

	if(!szKvsCommand.isEmpty())
		KviKvsScript::run(szKvsCommand,m_pKviWindow,&lParams);
}
bool KviPackageIOEngine::readError()
{
	setLastError(__tr2qs("File read error"));
	return false;
}
Exemple #29
0
KviInput::KviInput(KviWindow * pPar, KviUserListView * pView)
: QWidget(pPar)
{
	setObjectName("input_widget");
	m_pLayout=new QGridLayout(this);

	m_pLayout->setMargin(0);
	m_pLayout->setSpacing(0);

	m_pWindow = pPar;
	m_pMultiLineEditor = 0;

	m_pHideToolsButton = new QToolButton(this);
	m_pHideToolsButton->setObjectName("hide_container_button");

	m_pHideToolsButton->setIconSize(QSize(22,22));
	m_pHideToolsButton->setFixedWidth(16);

	if(g_pIconManager->getBigIcon("kvi_horizontal_left.png"))
		m_pHideToolsButton->setIcon(QIcon(*(g_pIconManager->getBigIcon("kvi_horizontal_left.png"))));

	connect(m_pHideToolsButton,SIGNAL(clicked()),this,SLOT(toggleToolButtons()));

	m_pButtonContainer = new KviTalHBox(this);
	m_pButtonContainer->setSpacing(0);
	m_pButtonContainer->setMargin(0);

	m_pButtonContainer->setSizePolicy(QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum));
	//if(m_pButtonContainer->layout())
	// m_pButtonContainer->layout()->setSizeConstraint(QLayout::SetMinimumSize);

	m_pHistoryButton = new QToolButton(m_pButtonContainer);
	m_pHistoryButton->setObjectName("historybutton");

	m_pHistoryButton->setIconSize(QSize(22,22));
	//m_pHistoryButton->setUpdatesEnabled(true); ???
	QIcon is1;
	if(KVI_OPTION_BOOL(KviOption_boolEnableInputHistory))//G&N mar 2005
	{
		is1.addPixmap(*(g_pIconManager->getSmallIcon(KviIconManager::History)));
		m_pHistoryButton->setIcon(is1);
		KviTalToolTip::add(m_pHistoryButton,__tr2qs("Show history<br>&lt;Ctrl+PageUp&gt;"));
		connect(m_pHistoryButton,SIGNAL(clicked()),this,SLOT(historyButtonClicked()));
	} else {
		is1.addPixmap(*(g_pIconManager->getSmallIcon(KviIconManager::HistoryOff)));
		m_pHistoryButton->setIcon(is1);
		KviTalToolTip::add(m_pHistoryButton,__tr2qs("Input history disabled"));
	}

	m_pIconButton = new QToolButton(m_pButtonContainer);
	m_pIconButton->setObjectName("iconbutton");

	m_pIconButton->setIconSize(QSize(22,22));
	QIcon is3;
	is3.addPixmap(*(g_pIconManager->getSmallIcon(KviIconManager::BigGrin)));
	m_pIconButton->setIcon(is3);
	KviTalToolTip::add(m_pIconButton,__tr2qs("Show icons popup<br>&lt;Ctrl+I&gt;<br>See also /help texticons"));
	connect(m_pIconButton,SIGNAL(clicked()),this,SLOT(iconButtonClicked()));

	m_pCommandlineModeButton = new QToolButton(m_pButtonContainer);
	m_pCommandlineModeButton->setObjectName("commandlinemodebutton");

	m_pCommandlineModeButton->setIconSize(QSize(22,22));
	m_pCommandlineModeButton->setCheckable(true);
	QIcon is0;
	is0.addPixmap(*(g_pIconManager->getSmallIcon(KviIconManager::SaySmile)),QIcon::Normal,QIcon::On);
	is0.addPixmap(*(g_pIconManager->getSmallIcon(KviIconManager::SayKvs)),QIcon::Normal,QIcon::Off);
	m_pCommandlineModeButton->setIcon(is0);
	KviTalToolTip::add(m_pCommandlineModeButton,__tr2qs("User friendly commandline mode<br>See also /help commandline"));
	if(KVI_OPTION_BOOL(KviOption_boolCommandlineInUserFriendlyModeByDefault))
		m_pCommandlineModeButton->setChecked(true);


	m_pMultiEditorButton = new QToolButton(m_pButtonContainer);
	m_pMultiEditorButton->setObjectName("multieditorbutton");

	m_pMultiEditorButton->setCheckable(true);
	m_pMultiEditorButton->setIconSize(QSize(22,22));
	QIcon is2;
	is2.addPixmap(*(g_pIconManager->getSmallIcon(KviIconManager::IrcView)),QIcon::Normal,QIcon::On);
	is2.addPixmap(*(g_pIconManager->getSmallIcon(KviIconManager::Terminal)),QIcon::Normal,QIcon::Off);
	m_pMultiEditorButton->setIcon(is2);
	QString szTip = __tr2qs("Multi-line editor<br>&lt;Alt+Return&gt;");
	KviTalToolTip::add(m_pMultiEditorButton,szTip);

	connect(m_pMultiEditorButton,SIGNAL(toggled(bool)),this,SLOT(multiLineEditorButtonToggled(bool)));

	m_pInputEditor = new KviInputEditor(this,pPar,pView);
	connect(m_pInputEditor,SIGNAL(enterPressed()),this,SLOT(inputEditorEnterPressed()));
	m_pInputEditor->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Ignored));

	m_pMultiEditorButton->setAutoRaise(true);
	m_pCommandlineModeButton->setAutoRaise(true);
	m_pIconButton->setAutoRaise(true);
	m_pHistoryButton->setAutoRaise(true);
	m_pHideToolsButton->setAutoRaise(true);

	m_pLayout->addWidget(m_pHideToolsButton,0,2,2,1);
	m_pLayout->addWidget(m_pButtonContainer,0,1,2,1);
	m_pLayout->addWidget(m_pInputEditor,0,0,2,1);

	installShortcuts();
}
bool KviApplication::checkUriAssociations(const char * pcProto)
{
#define QUERY_BUFFER 2048
	char * pcBuffer;
	DWORD len = QUERY_BUFFER;
	DWORD err;
	pcBuffer = (char *)malloc(len * sizeof(char));
	HKEY hKey;

	KviCString szStoredKey = pcProto;
	KviCString szKey = szStoredKey;

	len = QUERY_BUFFER;
	if(RegOpenKeyEx(HKEY_CLASSES_ROOT, szKey, 0, KEY_READ, &hKey) != ERROR_SUCCESS)
	{
		free(pcBuffer);
		return false;
	}

	if((err = RegQueryValueEx(hKey, 0, 0, 0, (LPBYTE)pcBuffer, &len)) != ERROR_SUCCESS)
	{
		free(pcBuffer);
		return false;
	}
	else
	{
		if(!kvi_strEqualCI(__tr2qs("URL:IRC Protocol").toLocal8Bit().data(), pcBuffer))
		{
			free(pcBuffer);
			return false;
		}
	}

	len = QUERY_BUFFER;
	if((err = RegQueryValueEx(hKey, "URL Protocol", 0, 0, (LPBYTE)pcBuffer, &len)) != ERROR_SUCCESS)
	{
		free(pcBuffer);
		return false;
	}

	szKey = szStoredKey + "\\DefaultIcon";
	len = QUERY_BUFFER;
	if(RegOpenKeyEx(HKEY_CLASSES_ROOT, szKey, 0, KEY_READ, &hKey) != ERROR_SUCCESS)
	{
		free(pcBuffer);
		return false;
	}

	if(RegQueryValueEx(hKey, 0, 0, 0, (LPBYTE)pcBuffer, &len) != ERROR_SUCCESS)
	{
		free(pcBuffer);
		return false;
	}
	else
	{
		QString szIcon = applicationFilePath() + ",0";
		szIcon.replace('/', "\\");
		if(!kvi_strEqualCI(szIcon.toLocal8Bit().data(), pcBuffer))
		{
			free(pcBuffer);
			return false;
		}
	}

	len = QUERY_BUFFER;
	szKey = szStoredKey + "\\Shell\\open";
	if(RegOpenKeyEx(HKEY_CLASSES_ROOT, szKey, 0, KEY_READ, &hKey) != ERROR_SUCCESS)
	{
		free(pcBuffer);
		return false;
	}

	if(RegQueryValueEx(hKey, 0, 0, 0, (LPBYTE)pcBuffer, &len) != ERROR_SUCCESS)
	{
		free(pcBuffer);
		return false;
	}
	else
	{
		if(!kvi_strEqualCI(__tr2qs("Open with KVIrc").toLocal8Bit().data(), pcBuffer))
		{
			free(pcBuffer);
			return false;
		}
	}

	len = QUERY_BUFFER;
	szKey = szStoredKey + "\\Shell\\open\\command";
	if(RegOpenKeyEx(HKEY_CLASSES_ROOT, szKey, 0, KEY_READ, &hKey) != ERROR_SUCCESS)
	{
		free(pcBuffer);
		return false;
	}

	if(RegQueryValueEx(hKey, 0, 0, 0, (LPBYTE)pcBuffer, &len) != ERROR_SUCCESS)
	{
		free(pcBuffer);
		return false;
	}
	else
	{
		QString szCmd = applicationFilePath() + " \"%1\"";
		szCmd.replace('/', "\\");
		if(!kvi_strEqualCI(szCmd.toLocal8Bit().data(), pcBuffer))
		{
			free(pcBuffer);
			return false;
		}
	}

	free(pcBuffer);
#else
bool KviApplication::checkUriAssociations(const char *)
{
#endif
	return true;
}

#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)
void KviApplication::setupUriAssociations(const char * pcProto)
{
	HKEY hKey;
	DWORD err;

	KviCString szStoredKey = pcProto;
	KviCString szKey = szStoredKey;

	QByteArray tmp;
	QString szAppPath = applicationFilePath();
	szAppPath.replace('/', "\\");

	SHDeleteKey(HKEY_CLASSES_ROOT, szKey);

	err = RegCreateKeyEx(HKEY_CLASSES_ROOT, szKey, 0, 0, 0, KEY_WRITE, 0, &hKey, 0);
	RegSetValueEx(hKey, 0, 0, REG_SZ, (LPBYTE) "URL:IRC Protocol", 16);
	RegSetValueEx(hKey, "URL Protocol", 0, REG_SZ, (LPBYTE) "", 0);

	szKey = szStoredKey + "\\DefaultIcon";
	RegCreateKeyEx(HKEY_CLASSES_ROOT, szKey, 0, 0, 0, KEY_WRITE, 0, &hKey, 0);
	tmp = QString(szAppPath + ",0").toLocal8Bit();
	RegSetValueEx(hKey, 0, 0, REG_SZ, (LPBYTE)tmp.data(), tmp.length());

	szKey = szStoredKey + "\\Shell\\open";
	RegCreateKeyEx(HKEY_CLASSES_ROOT, szKey, 0, 0, 0, KEY_WRITE, 0, &hKey, 0);
	tmp = __tr2qs("Open with KVIrc").toLocal8Bit();
	RegSetValueEx(hKey, 0, 0, REG_SZ, (LPBYTE)tmp.data(), tmp.length());

	szKey = szStoredKey + "\\Shell\\open\\command";
	RegCreateKeyEx(HKEY_CLASSES_ROOT, szKey, 0, 0, 0, KEY_WRITE, 0, &hKey, 0);
	tmp = QString(szAppPath + " --external \"%1\"").toLocal8Bit();
	RegSetValueEx(hKey, 0, 0, REG_SZ, (LPBYTE)tmp.data(), tmp.length());
#else
void KviApplication::setupUriAssociations(const char *)
{
#endif
}

void KviApplication::setupFileAssociations()
{
#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)
	HKEY hKey;
	DWORD err;

	QByteArray tmp;
	QString szAppPath = applicationFilePath();
	szAppPath.replace('/', "\\");

	SHDeleteKey(HKEY_CLASSES_ROOT, ".kvs");

	err = RegCreateKeyEx(HKEY_CLASSES_ROOT, ".kvs", 0, 0, 0, KEY_WRITE, 0, &hKey, 0);
	RegSetValueEx(hKey, 0, 0, REG_SZ, (LPBYTE) "KVIrcScript", 11);

	SHDeleteKey(HKEY_CLASSES_ROOT, "KVIrcScript");
	RegCreateKeyEx(HKEY_CLASSES_ROOT, "KVIrcScript", 0, 0, 0, KEY_WRITE, 0, &hKey, 0);
	tmp = __tr2qs("KVIrc KVS Script").toLocal8Bit();
	RegSetValueEx(hKey, 0, 0, REG_SZ, (LPBYTE)tmp.data(), tmp.length());

	RegCreateKeyEx(HKEY_CLASSES_ROOT, "KVIrcScript\\DefaultIcon", 0, 0, 0, KEY_WRITE, 0, &hKey, 0);
	tmp = QString(szAppPath + ",1").toLocal8Bit();
	RegSetValueEx(hKey, 0, 0, REG_SZ, (LPBYTE)tmp.data(), tmp.length());

	RegCreateKeyEx(HKEY_CLASSES_ROOT, "KVIrcScript\\Shell\\Parse", 0, 0, 0, KEY_WRITE, 0, &hKey, 0);
	tmp = __tr2qs("Run KVS Script").toLocal8Bit();
	RegSetValueEx(hKey, 0, 0, REG_SZ, (LPBYTE)tmp.data(), tmp.length());

	RegCreateKeyEx(HKEY_CLASSES_ROOT, "KVIrcScript\\Shell\\Parse\\command", 0, 0, 0, KEY_WRITE, 0, &hKey, 0);
	tmp = QString(szAppPath + " \"%1\"").toLocal8Bit();
	RegSetValueEx(hKey, 0, 0, REG_SZ, (LPBYTE)tmp.data(), tmp.length());

	//Configs
	SHDeleteKey(HKEY_CLASSES_ROOT, ".kvc");

	err = RegCreateKeyEx(HKEY_CLASSES_ROOT, ".kvc", 0, 0, 0, KEY_WRITE, 0, &hKey, 0);
	RegSetValueEx(hKey, 0, 0, REG_SZ, (LPBYTE) "KVIrcConfig", 11);

	SHDeleteKey(HKEY_CLASSES_ROOT, "KVIrcConfig");
	RegCreateKeyEx(HKEY_CLASSES_ROOT, "KVIrcConfig", 0, 0, 0, KEY_WRITE, 0, &hKey, 0);
	tmp = __tr2qs("KVIrc Configuration File").toLocal8Bit();
	RegSetValueEx(hKey, 0, 0, REG_SZ, (LPBYTE)tmp.data(), tmp.length());

	RegCreateKeyEx(HKEY_CLASSES_ROOT, "KVIrcConfig\\DefaultIcon", 0, 0, 0, KEY_WRITE, 0, &hKey, 0);
	tmp = QString(szAppPath + ",2").toLocal8Bit();
	RegSetValueEx(hKey, 0, 0, REG_SZ, (LPBYTE)tmp.data(), tmp.length());

	// Themes
	SHDeleteKey(HKEY_CLASSES_ROOT, ".kvt");

	err = RegCreateKeyEx(HKEY_CLASSES_ROOT, ".kvt", 0, 0, 0, KEY_WRITE, 0, &hKey, 0);
	RegSetValueEx(hKey, 0, 0, REG_SZ, (LPBYTE) "KVIrcTheme", 11);

	SHDeleteKey(HKEY_CLASSES_ROOT, "KVIrcTheme");
	RegCreateKeyEx(HKEY_CLASSES_ROOT, "KVIrcTheme", 0, 0, 0, KEY_WRITE, 0, &hKey, 0);
	tmp = __tr2qs("KVIrc Theme Package").toLocal8Bit();
	RegSetValueEx(hKey, 0, 0, REG_SZ, (LPBYTE)tmp.data(), tmp.length());

	RegCreateKeyEx(HKEY_CLASSES_ROOT, "KVIrcTheme\\DefaultIcon", 0, 0, 0, KEY_WRITE, 0, &hKey, 0);
	tmp = QString(szAppPath + ",3").toLocal8Bit();
	RegSetValueEx(hKey, 0, 0, REG_SZ, (LPBYTE)tmp.data(), tmp.length());

	RegCreateKeyEx(HKEY_CLASSES_ROOT, "KVIrcTheme\\Shell\\Install", 0, 0, 0, KEY_WRITE, 0, &hKey, 0);
	tmp = __tr2qs("Install Theme Package").toLocal8Bit();
	RegSetValueEx(hKey, 0, 0, REG_SZ, (LPBYTE)tmp.data(), tmp.length());

	RegCreateKeyEx(HKEY_CLASSES_ROOT, "KVIrcTheme\\Shell\\Install\\command", 0, 0, 0, KEY_WRITE, 0, &hKey, 0);
	tmp = QString(szAppPath + " \"%1\"").toLocal8Bit();
	RegSetValueEx(hKey, 0, 0, REG_SZ, (LPBYTE)tmp.data(), tmp.length());

	//Addons
	SHDeleteKey(HKEY_CLASSES_ROOT, ".kva");

	err = RegCreateKeyEx(HKEY_CLASSES_ROOT, ".kva", 0, 0, 0, KEY_WRITE, 0, &hKey, 0);
	RegSetValueEx(hKey, 0, 0, REG_SZ, (LPBYTE) "KVIrcAddon", 11);

	SHDeleteKey(HKEY_CLASSES_ROOT, "KVIrcAddon");
	RegCreateKeyEx(HKEY_CLASSES_ROOT, "KVIrcAddon", 0, 0, 0, KEY_WRITE, 0, &hKey, 0);
	tmp = __tr2qs("KVIrc Addon Package").toLocal8Bit();
	RegSetValueEx(hKey, 0, 0, REG_SZ, (LPBYTE)tmp.data(), tmp.length());

	RegCreateKeyEx(HKEY_CLASSES_ROOT, "KVIrcAddon\\DefaultIcon", 0, 0, 0, KEY_WRITE, 0, &hKey, 0);
	tmp = QString(szAppPath + ",4").toLocal8Bit();
	RegSetValueEx(hKey, 0, 0, REG_SZ, (LPBYTE)tmp.data(), tmp.length());

	RegCreateKeyEx(HKEY_CLASSES_ROOT, "KVIrcAddon\\Shell\\Install", 0, 0, 0, KEY_WRITE, 0, &hKey, 0);
	tmp = __tr2qs("Install Package").toLocal8Bit();
	RegSetValueEx(hKey, 0, 0, REG_SZ, (LPBYTE)tmp.data(), tmp.length());

	RegCreateKeyEx(HKEY_CLASSES_ROOT, "KVIrcAddon\\Shell\\Install\\command", 0, 0, 0, KEY_WRITE, 0, &hKey, 0);
	tmp = QString(szAppPath + " \"%1\"").toLocal8Bit();
	RegSetValueEx(hKey, 0, 0, REG_SZ, (LPBYTE)tmp.data(), tmp.length());

#endif
}