示例#1
0
TwitterEditAccountWidget::TwitterEditAccountWidget(TwitterMicroBlog *microblog,
                                                    TwitterAccount* account, QWidget* parent)
    : ChoqokEditAccountWidget(account, parent), mAccount(account)
{
    setupUi(this);
    kcfg_basicAuth->hide();
    connect(kcfg_authorize, SIGNAL(clicked(bool)), SLOT(authorizeUser()));
    if(mAccount) {
        kcfg_alias->setText( mAccount->alias() );
        if(mAccount->oauthToken().isEmpty() || mAccount->oauthTokenSecret().isEmpty()) {
            setAuthenticated(false);
        } else {
            setAuthenticated(true);
            token = mAccount->oauthToken();
            tokenSecret = mAccount->oauthTokenSecret();
            username = mAccount->username();
        }
    } else {
        setAuthenticated(false);
        QString newAccountAlias = microblog->serviceName();
        QString servName = newAccountAlias;
        int counter = 1;
        while(Choqok::AccountManager::self()->findAccount(newAccountAlias)){
            newAccountAlias = QString("%1%2").arg(servName).arg(counter);
        counter++;
    }
        setAccount( mAccount = new TwitterAccount(microblog, newAccountAlias) );
        kcfg_alias->setText( newAccountAlias );
    }
    loadTimelinesTableState();
    kcfg_alias->setFocus(Qt::OtherFocusReason);
}
Kopete::Account*
GaduEditAccount::apply()
{
	publishUserInfo();
	
	if ( account() == NULL ) {
		setAccount( new GaduAccount( protocol_, loginEdit_->text() ) );
		account_ = static_cast<GaduAccount*>( account() );
	}

	account_->setExcludeConnect( autoLoginCheck_->isChecked() );

	passwordWidget_->save( &account_->password() );

	account_->myself()->setNickName( nickName->text() );

	// this is changed only here, so i won't add any proper handling now
        account_->configGroup()->writeEntry( QString::fromAscii( "nickName" ), nickName->text() );

	account_->setExcludeConnect( autoLoginCheck_->isChecked() );
	account_->setUseTls( (GaduAccount::tlsConnection) useTls_->currentIndex() );
	account_->setExportListOnChange(exportCheck_->isChecked());
	account_->setImportListOnLogin(importCheck_->isChecked());

	account_->setIgnoreAnons( ignoreCheck_->isChecked() );

	if ( account_->setDcc( dccCheck_->isChecked() ) == false ) {
		KMessageBox::sorry( this, i18n( "<b>Starting DCC listening socket failed; dcc is not working now.</b>" ), i18n( "Gadu-Gadu" ) );
	}

	return account();
}
示例#3
0
void gajim::loadMessages(const QString &path)
{
	QDir dir = path;
	QFileInfo info(dir.filePath("logs.db"));
	if(!info.exists())
		return;
	QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
	db.setDatabaseName(info.absoluteFilePath());
	if(!db.open())
		return;
	setProtocol("jabber");
	setAccount(m_account);
	QSqlQuery jid_query("SELECT jid_id, jid FROM jids", db);
	setMaxValue(jid_query.size());
	int num = 0;
	while(jid_query.next())
	{
		QString jid_id = jid_query.value(0).toString();
		QString jid = jid_query.value(1).toString();
		setContact(jid);
		static QString query_str = "SELECT time, message, kind FROM logs "
								   "WHERE jid_id = %1 AND (kind = 4 OR kind = 6) "
								   "ORDER BY time ASC";
		QSqlQuery query(query_str.arg(jid_id), db);
		while(query.next())
		{
			Message message;
			message.setTime(QDateTime::fromTime_t(query.value(0).toInt()));
			message.setIncoming(query.value(2).toInt() == 4);
			message.setText(query.value(1).toString());
			appendMessage(message);
		}
		setValue(++num);
	}
}
void skypeEditAccount::configureSkypeClient() {
	kDebug(SKYPE_DEBUG_GLOBAL);

	if ( ! account() )
		setAccount(new SkypeAccount(d->protocol, "Skype"));

	QByteArray authAppName = ( static_cast <SkypeAccount *> (account()) )->author.toUtf8();

	if ( authAppName.isEmpty() )
		authAppName = "Kopete";

	QString skypeUser = ( static_cast <SkypeAccount *> (account()) )->getMyselfSkypeName();

	if ( skypeUser.isEmpty() )
		skypeUser = KInputDialog::getText(i18n("Configure Skype client"), i18n("Please enter your skype user name"));

	if ( skypeUser.isEmpty() ) {
		KMessageBox::error(this, i18n("You must enter your skype user name"), i18n("Skype protocol"));
		return;
	}

	const QString &skypeDir = QString("%1/.Skype").arg(QDir::homePath());
	QDir dir(skypeDir);

	if ( ! dir.exists(skypeDir) )
		dir.mkpath(skypeDir);

	const QString &sharedPath = QString("%1/shared.xml").arg(skypeDir);
	QFile sharedFile(sharedPath);

	if ( ! sharedFile.open(QIODevice::WriteOnly) ) {
		kDebug(SKYPE_DEBUG_GLOBAL) << "Cant create/open file" << sharedPath;
		KMessageBox::error(this, i18n("Cannot create/open file %1 for configuring the Skype client.", sharedPath), i18n("Skype protocol"));
		return;
	}

	sharedFile.reset();
	sharedFile.write("<?xml version=\"1.0\"?>\n<config version=\"1.0\" serial=\"9\" timestamp=\"0\">\n  <UI>\n    <Installed>2</Installed>\n    <Language>en</Language>\n    <SavePassword>1</SavePassword>\n    <StartMinimized>1</StartMinimized>\n  </UI>\n</config>\n"); //This only works with Linux Skype Client versions: 2.0.0.72 2.1.0.47 2.1.0.81
	sharedFile.close();

	const QString &userDir = QString("%1/%2").arg(skypeDir).arg(skypeUser);
	if ( ! dir.exists(userDir) )
		dir.mkpath(userDir);

	const QString &configPath = QString("%1/config.xml").arg(userDir);
	QFile configFile(configPath);

	if ( ! configFile.open(QIODevice::WriteOnly) ) {
		kDebug(SKYPE_DEBUG_GLOBAL) << "Cant create/open file" << configPath;
		KMessageBox::error(this, i18n("Cannot create/open file %1 for configuring the Skype client.", configPath), i18n("Skype protocol"));
		return;
	}

	configFile.reset();
	configFile.write("<?xml version=\"1.0\"?>\n<config version=\"1.0\" serial=\"9\" timestamp=\"0\">\n  <UI>\n    <API>\n      <Authorizations>" + authAppName + "</Authorizations>\n    </API>\n    <Notifications>\n      <Enable>\n        <Birthday>0</Birthday>\n        <CallAnswered>1</CallAnswered>\n        <CallBusy>1</CallBusy>\n        <CallFailed>1</CallFailed>\n        <CallHangup>1</CallHangup>\n        <CallHold>1</CallHold>\n        <CallMissed>1</CallMissed>\n        <CallRemoteHangup>1</CallRemoteHangup>\n        <CallResume>1</CallResume>\n        <CallRingingIn>1</CallRingingIn>\n        <CallRingingOut>1</CallRingingOut>\n        <ChatIncoming>0</ChatIncoming>\n        <ChatIncomingInitial>0</ChatIncomingInitial>\n        <ChatJoined>0</ChatJoined>\n        <ChatOutgoing>0</ChatOutgoing>\n        <ChatParted>0</ChatParted>\n        <ContactAdded>0</ContactAdded>\n        <ContactAuthRequest>0</ContactAuthRequest>\n        <ContactDeleted>0</ContactDeleted>\n        <ContactOffline>0</ContactOffline>\n        <ContactOnline>0</ContactOnline>\n        <SkypeLogin>0</SkypeLogin>\n        <SkypeLoginFailed>0</SkypeLoginFailed>\n        <SkypeLogout>0</SkypeLogout>\n        <TransferComplete>1</TransferComplete>\n        <TransferFailed>1</TransferFailed>\n        <VoicemailReceived>1</VoicemailReceived>\n        <VoicemailSent>1</VoicemailSent>\n      </Enable>\n    </Notifications>\n    <Notify>\n      <Call>0</Call>\n    </Notify>\n  </UI>\n</config>\n"); //This only works with Linux Skype Client versions: 2.0.0.72 2.1.0.47 2.1.0.81
	configFile.close();

	KMessageBox::information(this, i18n("Process has completed.\nSkype is now configured for Kopete.\nYou must restart the Skype client for changes to take effect."), i18n("Skype protocol"));
}
示例#5
0
void andrq::loadMessages(const QString &path)
{
	QDir dir = path;
	QString account = dir.dirName();
	if(!dir.cd("history"))
		return;
	setProtocol("ICQ");
	setAccount(account);
	QFileInfoList files = dir.entryInfoList(QDir::Files);
	setMaxValue(files.size());
	for(int i = 0; i < files.size(); i++)
	{
		setValue(i + 1);
		QString uin = files[i].fileName();
		QFile file(files[i].absoluteFilePath());
		if(!file.open(QFile::ReadOnly))
			continue;
		setContact(uin);
		QDataStream in(&file);
		in.setByteOrder(QDataStream::LittleEndian);
		Message message;
		message.type=1;
		while(!in.atEnd())
		{
			qint32 type;
			in >> type;
			switch(type)
			{
			case -1: {
				quint8 kind;
				qint32 who;
				in >> kind >> who;
				QString from = QString::number(who);
				message.in = from == uin;
				message.time = getDateTime(in);
				qint32 tmp;
				in >> tmp;
				in.skipRawData(tmp);
				message.text = Qt::escape(getString(in, who)).replace("\n", "<br/>");
				if(kind==1)
					appendMessage(message);
				break; }
			case -2: {
				qint32 tmp;
				in >> tmp;
				in.skipRawData(tmp);
				break; }
			case -3:
				in.skipRawData(5);
				break;
			default:
				break;
			}
		}
	}
}
void SmtpClient::accountsUpdated(const QMailAccountIdList &ids)
{
    if (!ids.contains(account()))
        return;

    QMailAccount acc(account());
    bool isEnabled(acc.status() & QMailAccount::Enabled);
    if (!isEnabled)
        return;
    setAccount(account());
}
SIM::Account *skypeEditAccount::apply() {
	kdDebug(14311) << k_funcinfo << endl;//some debug info

	//first, I need a pointer to that account
	if (!account()) //it does not exist
		setAccount(new SkypeAccount(d->protocol));//create a new one
	SkypeAccount *skype = static_cast<SkypeAccount *>(account());//get the account

	//set it's values
	skype->setExcludeConnect(excludeCheck->isChecked());//Save the "exclude from connection" setup
	skype->launchType = LaunchGroup->selectedId();//get the type how to launch skype
	if (AuthorCheck->isChecked())
		skype->author = AuthorEdit->text();//put there what user wrote
	else
		skype->author = "";//nothing unusual
	skype->setHitchHike(HitchCheck->isChecked());//save the hitch hike mode and activat ethe new value
	skype->setMarkRead(MarkCheck->isChecked());//set the mark read messages mode and activate it
	skype->setScanForUnread(ScanCheck->isChecked());
	skype->setCallControl(CallCheck->isChecked());
	skype->setPings(PingsCheck->isChecked());
	skype->setBus(BusGroup->selectedId());
	skype->setStartDBus(DBusCheck->isChecked());
	skype->setLaunchTimeout(LaunchSpin->value());
	skype->setSkypeCommand(CommandEdit->text());
	skype->setWaitBeforeConnect(WaitSpin->value());
	skype->setLeaveOnExit(LeaveCheck->isChecked());
	if (AutoCloseCallCheck->isChecked()) {
		skype->setCloseWindowTimeout(CloseTimeoutSpin->value());
	} else {
		skype->setCloseWindowTimeout(0);
	}
	if (StartCallCommandCheck->isChecked()) {
		skype->setStartCallCommand(StartCallCommandEdit->text());
	} else {
		skype->setStartCallCommand("");
	}
	skype->setWaitForStartCallCommand(WaitForStartCallCommandCheck->isChecked());
	if (EndCallCommandCheck->isChecked()) {
		skype->setEndCallCommand(EndCallCommandEdit->text());
	} else {
		skype->setEndCallCommand("");
	}
	if (IncomingCommandCheck->isChecked()) {
		skype->setIncomingCommand(IncomingCommandEdit->text());
	} else {
		skype->setIncomingCommand("");
	}

	skype->setEndCallCommandOnlyForLast(OnlyLastCallCommandCheck->isChecked());
	skype->save();//save it to config
	return skype;//return the account
}
Kopete::Account *WPEditAccount::apply()
{
	kDebug(14170) << "WPEditAccount::apply()";

	if(!account())
		setAccount(new WPAccount(mProtocol, mHostName->text()));

//	account()->setExcludeConnect(mAutoConnect->isChecked());
	writeConfig();

	mProtocol->settingsChanged();

	return account();
}
示例#9
0
void cPlayer::load( cBufferedReader& reader, unsigned int version )
{
	cBaseChar::load( reader, version );
	setAccount( Accounts::instance()->getRecord( reader.readUtf8() ) );
	additionalFlags_ = reader.readInt();
	visualRange_ = reader.readByte();
	profile_ = reader.readUtf8();
	fixedLightLevel_ = reader.readByte();
	strengthLock_ = reader.readByte();
	dexterityLock_ = reader.readByte();
	intelligenceLock_ = reader.readByte();
	if (version > 7) {
		maxControlSlots_ = reader.readByte();
	}
}
示例#10
0
void cPlayer::load( QSqlQuery& result, ushort& offset )
{
	cBaseChar::load( result, offset );

	setAccount( Accounts::instance()->getRecord( result.value( offset++ ).toString() ) );
	additionalFlags_ = result.value( offset++ ).toInt();
	visualRange_ = result.value( offset++ ).toInt();
	profile_ = result.value( offset++ ).toString();
	fixedLightLevel_ = result.value( offset++ ).toInt();
	strengthLock_ = result.value( offset++ ).toInt();
	dexterityLock_ = result.value( offset++ ).toInt();
	intelligenceLock_ = result.value( offset++ ).toInt();
	maxControlSlots_ = result.value( offset++ ).toInt();

	changed_ = false;
}
示例#11
0
//ISSUE 2: Unsafe char *user input
//ISSUE 3: Unsafe char *password input 
int addUser(char * user, char * password){
	FILE * file;
	char fileName[100];
	// 
	file=fopen("/vulnerable/passwords","r+");
	fseek(file, 0, SEEK_END);
	fputs(user,file);
	fputs(" ",file);
	fputs(password,file);
	fputs("\n",file);
	fclose(file);

	setAccount(user,100);

	return 0;
}
示例#12
0
void cPlayer::load( char** result, Q_UINT16& offset )
{
	cBaseChar::load( result, offset );

	setAccount( Accounts::instance()->getRecord( result[offset++] ) );
	additionalFlags_ = atoi( result[offset++] );
	visualRange_ = atoi( result[offset++] );
	profile_ = result[offset++];
	fixedLightLevel_ = atoi( result[offset++] );
	strengthLock_ = atoi( result[offset++] );
	dexterityLock_ = atoi( result[offset++] );
	intelligenceLock_ = atoi( result[offset++] );
	maxControlSlots_ = atoi( result[offset++] );

	playerRegisterAfterLoading( this );
	changed_ = false;
}
示例#13
0
void AccountsComboBox::setController(PsiCon* controller)
{
	if (controller_) {
		disconnect(controller_, SIGNAL(accountCountChanged()), this, SLOT(updateAccounts()));
		disconnect(controller_, SIGNAL(accountActivityChanged()), this, SLOT(updateAccounts()));
	}

	controller_ = controller;

	if (controller_) {
		connect(controller_, SIGNAL(accountCountChanged()), this, SLOT(updateAccounts()));
		connect(controller_, SIGNAL(accountActivityChanged()), this, SLOT(updateAccounts()));
	}

	if (controller_->contactList()->haveEnabledAccounts()) {
		setAccount(controller_->contactList()->enabledAccounts().first());
	}

	updateAccounts();
}
示例#14
0
/**
   @brief Restore a todo list from a QVariant representation
   @sa toVariant()
 */
void TodoList::fromVariant(const QVariant &todolist)
{
  m_loading = true;
  QVariantMap map = todolist.toMap();

  // Special handling for id: Only update if identify changes
  if ( m_uuid != map.value( "uuid", QUuid() ).toUuid() || !m_hasId ) {
    m_hasId = map.contains( "id" );
    if ( m_hasId ) {
      setId( map.value( "id", m_id ).toInt() );
    }
  }

  setAccount( map.value( "accountUuid", m_accountUuid ).toUuid() );
  setMetaAttributes( map.value( "metaAttributes", m_metaAttributes ).toMap() );
  setName( map.value( "name", m_name ).toString() );
  setUuid( map.value( "uuid", m_uuid ).toUuid() );
  setDirty( map.value( "dirty", m_dirty ).toInt() );
  setDisposed( map.value( "disposed", m_disposed ).toBool() );
  m_loading = false;
}
示例#15
0
void psi::loadMessages(const QString &path)
{
	QDir dir = path;
	if(!dir.cd("history"))
		return;
	QFileInfoList files = dir.entryInfoList(QStringList() << "*.history", QDir::Files);
	setProtocol("jabber");
	setAccount(m_account);
	setMaxValue(files.size());
	for(int i = 0; i < files.size(); i++)
	{
		setValue(i + 1);
		QString contact = files[i].fileName();
		contact.chop(4);
		contact = decode(contact);
		setContact(contact);
		QFile file(files[i].absoluteFilePath());
		if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
			continue;
		QTextStream in(&file);
		in.setCodec("utf-8");
		while(!in.atEnd())
		{
			static const QChar c('|');
			QString line = in.readLine();
			if(line.isEmpty())
				continue;
			// |2008-07-13T15:27:57|5|from|N3--|Цитата #397796|http://bash.org.ru/quote/397796|Цитата #397796|xxx: cool text
			Message message;
			message.setTime(QDateTime::fromString(line.section(c, 1, 1), Qt::ISODate));
			message.setIncoming(line.section(c, 3, 3) == "from");
			QString text = line.mid(line.lastIndexOf(c) + 1);
			int psi_type = line.section(c, 2, 2).toInt();
			if(psi_type == 2 || psi_type == 3 || psi_type == 6 || psi_type == 7 || psi_type == 8 || text.isEmpty())
				continue;
			message.setText(logdecode(text));
			appendMessage(message);
		}
	}
}
AccountInterfacePrivate::AccountInterfacePrivate(AccountInterface *parent, Accounts::Account *acc)
    : QObject(parent)
    , q(parent)
    , manager(new Accounts::Manager)
    , account(0)
    , pendingSync(false)
    , pendingInitModifications(false)
    , identifier(0)
    , enabled(false)
    , identifierPendingInit(false)
    , providerNamePendingInit(false)
    , identityIdentifiersPendingInit(false)
    , enabledPendingInit(false)
    , displayNamePendingInit(false)
    , configurationValuesPendingInit(false)
    , enabledServiceNamesPendingInit(false)
    , status(AccountInterface::Initializing)
    , error(AccountInterface::NoError)
{
    if (acc)
        setAccount(acc);
}
Kopete::Account *YahooEditAccount::apply()
{
	kDebug(YAHOO_GEN_DEBUG) ;

	if ( !account() )
		setAccount( new YahooAccount( theProtocol, mScreenName->text().toLower() ) );

	YahooAccount *yahooAccount = static_cast<YahooAccount *>( account() );

	yahooAccount->setExcludeConnect( mAutoConnect->isChecked() );

	mPasswordWidget->save( &yahooAccount->password() );

	if ( optionOverrideServer->isChecked() )
	{
		yahooAccount->setServer( editServerAddress->text().trimmed() );
		yahooAccount->setPort( sbxServerPort->value() );
	}
	else
	{
		yahooAccount->setServer( "scsa.msg.yahoo.com" );
		yahooAccount->setPort( 5050 );
	}

	account()->configGroup()->writeEntry("pictureUrl", m_photoPath );
	account()->configGroup()->writeEntry("sendPicture", optionSendBuddyIcon->isChecked() );
	if ( optionSendBuddyIcon->isChecked() )
	{
		yahooAccount->setBuddyIcon( m_photoPath );
	}
	else
	{
		yahooAccount->setBuddyIcon( KUrl() );
	}
	
	return yahooAccount;
}
示例#18
0
int main(int argc, char *argv[]){

	char user[100];
	char password[100];
	char transaction[2048];
	int auth;

	int i;

	if(argc!=2 && argc!=4){
		printf("account password (to setup/report on your account)\n");
		printf("account password amount targetAccount (to transfer)\n");
		return 0;
	}

	strncpy(user,getenv("USER"),100); // determine who is running this

	/* for auditing purposes */
	transaction[0]='\0';
	strncat(transaction,user,2048);
	strncat(transaction,": ",2048);
	for(i=1;i<argc;i++){
		strncat(transaction,argv[i],2048);
		strncat(transaction," ",2048);
	}

	strncpy(password,argv[1],99);
	password[99]='\0';
	auth=authenticate(user, password);

	if(argc==2){ 
	
		if(auth==2){
			addUser(user, password);
			printf("Your account has:\n");
			report(user);
		} else if(auth==1){
			printf("Your account has:\n");
			report(user);
		} else {
			printf("You have not been authenticated\n");
		}
	} else if(argc==4){ // perform a transfer to another account
		if(auth==1){
			int fromAmount, amount, toAmount;
			//ISSUE 6: Possible unsafe (negative) amount input
			amount=atoi(argv[2]);
			fromAmount=getAccount(user);
			toAmount=getAccount(argv[3]);
			if(toAmount==-1){
				printf("account %s does not exist\n",argv[3]);
			} else if(fromAmount-amount>0){
				printf("Your account had:\n");
				report(user);

				fromAmount=fromAmount-amount;
				//ISSUE 5: Integer Overflow
				toAmount=toAmount+amount;
				setAccount(user,fromAmount);
				setAccount(argv[3],toAmount);

				printf("Your account now has:\n");
				report(user);
			} else {
				printf("You do not have sufficient credits.\n");
			}
		} else { 
			printf("You have not been authenticated\n");
		} 
	}

	/* in any case, log the attempt */
	logTransaction(transaction);

	return 0;
}
示例#19
0
void qippda::loadMessages(const QString &path)
{
	QDir dir = path;
	if(!dir.cd("History"))
		return;
	QHash<QString,QString> protocols;
	protocols[QLatin1String("icq")]    = QLatin1String("ICQ");
	protocols[QLatin1String("jabber")] = QLatin1String("Jabber");
	protocols[QLatin1String("mra")]    = QLatin1String("MRIM");
	QStringList filters = QStringList() << QLatin1String("*.qhf") << QLatin1String("*.ahf");
	QFileInfoList files = dir.entryInfoList(filters, QDir::Files);
	setMaxValue(files.size());
	for(int i = 0; i < files.size(); i++)
	{
		setValue(i + 1);
		QString protocol = files[i].fileName().section("_",0,0);
		while(!protocol.isEmpty() && protocol.at(protocol.length() - 1).isDigit())
			protocol.chop(1);
		// Old qip pda has only ICQ support and files are named like 1_myuin_hisuin
		if(protocol.isEmpty())
			protocol = QLatin1String("ICQ");
		else
		{
			protocol = protocols[protocol.toLower()];
			if(protocol.isEmpty())
			{
				qWarning("Unknown protocol: \"%s\"", qPrintable(files[i].fileName()));
				continue;
			}
		}
		setProtocol(protocol);
		QString account = files[i].fileName().section("_",1,1);
		setAccount(account);
		QFile file(files[i].absoluteFilePath());
		if(file.open(QFile::ReadOnly))
		{
			QByteArray bytearray = file.readAll();
			const uchar *data = (const uchar *)bytearray.constData();
			const uchar *end = data + bytearray.size();
			if(memcmp(data, "QHF", 3))
				continue;
			uchar version = data[3];
			data += 44;
			QString uin = qipinfium::getString(data, qipinfium::getUInt16(data));
			QString name = qipinfium::getString(data, qipinfium::getUInt16(data));
			setContact(uin);
//			continue;
			while(data < end)
			{
				quint16 type = qipinfium::getUInt16(data);
				quint32 index = qipinfium::getUInt32(data);
				data += 2;
				const uchar *next = data + index;
				if(type == 1)
				{
					Message message;
					message.type = 1;
					data += 10;
					message.time = QDateTime::fromTime_t(qipinfium::getUInt32(data));
					message.time.setTimeSpec(Qt::LocalTime);
					if(version == 1)
						message.time = message.time.toUTC().addDays(2);
					else
						message.time = message.time.toUTC();
					data += 4;
					message.in = qipinfium::getUInt8(data) == 0;
					data += 4;
					int mes_len = version == 3 ? qipinfium::getUInt32(data) : qipinfium::getUInt16(data);
					QString text = qipinfium::getString(data, mes_len, version > 1);
					message.text = Qt::escape(text).replace("\n", "<br/>");
					appendMessage(message);
				}
				else
					data = next;
			}
		}
	}
}
示例#20
0
// Simple setting and getting of properties for scripts and the set command.
stError* cPlayer::setProperty( const QString& name, const cVariant& value )
{
	changed( TOOLTIP );
	changed_ = true;

	/*
		\property char.account The name of the account assigned to this player.
		You can change the account by assignging a new name to this string property.
		This property is exclusive to player objects.
	*/
	if ( name == "account" )
	{
		setAccount( Accounts::instance()->getRecord( value.toString() ) );
		return 0;
	}
	/*
		\property char.logouttime This integer property is used when a player disconnects in an unsafe area.
		This property indicates the time when the character will disappear from the world.
		This property is exclusive to players.
	*/
	else
		SET_INT_PROPERTY( "logouttime", logoutTime_ )

	/*
		\property char.maxcontrolslots This property indicates how many control slots this character has.
		This property is exclusive to players.
	*/
	else
		SET_INT_PROPERTY( "maxcontrolslots", maxControlSlots_ )

		/*
		\property char.lightbonus This is the lightlevel bonus applied for this player.
		*/
	else
		SET_INT_PROPERTY( "lightbonus", fixedLightLevel_ )
		/*
		\property char.objectdelay If this integer property is not zero, it indicates the servertime in miliseconds
		when the player will be able to use an item again. Containers ignore this value.
		This property is exclusive to player objects.
		*/
	else
		SET_INT_PROPERTY( "objectdelay", objectDelay_ )
		/*
		\property char.visrange This integer property indicates how far the player can see in tiles.
		This property is exclusive to player objects.
		*/
	else
		SET_INT_PROPERTY( "visrange", visualRange_ )
		/*
		\property char.profile This string property contains the players profile.
		This property is exclusive to player objects.
		*/
	else
		SET_STR_PROPERTY( "profile", profile_ )
		/*
		\property char.strengthlock This integer property indicates the lock status for the players strength.
		It can be one of the following values:
		<code>0x00 Up
		0x01 Down
		0x02 Locked</code>
		This property is exclusive to player objects.
		*/
	else
		SET_INT_PROPERTY( "strengthlock", strengthLock_ )
		/*
		\property char.dexteritylock This integer property indicates the lock status for the players dexterity.
		It can be one of the following values:
		<code>0x00 Up
		0x01 Down
		0x02 Locked</code>
		This property is exclusive to player objects.
		*/
	else
		SET_INT_PROPERTY( "dexteritylock", dexterityLock_ )
		/*
		\property char.intelligencelock This integer property indicates the lock status for the players intelligence.
		It can be one of the following values:
		<code>0x00 Up
		0x01 Down
		0x02 Locked</code>
		This property is exclusive to player objects.
		*/
	else
		SET_INT_PROPERTY( "intelligencelock", intelligenceLock_ )
	else if ( name.left( 6 ) == "skill." )
	{
		QString skill = name.right( name.length() - 6 );
		Q_INT16 skillId = Skills::instance()->findSkillByDef( skill );

		if ( skillId != -1 )
		{
			setSkillValue( skillId, value.toInt() );
			if ( socket_ )
				socket_->sendSkill( skillId );
			return 0;
		}

		// skillcap.
	}
	else if ( name.left( 9 ) == "skillcap." )
	{
		QString skill = name.right( name.length() - 9 );
		Q_INT16 skillId = Skills::instance()->findSkillByDef( skill );

		if ( skillId != -1 )
		{
			setSkillCap( skillId, value.toInt() );
			if ( socket_ )
				socket_->sendSkill( skillId );
			return 0;
		}
	} else if ( name.startsWith( "account." ) && account_ ) {
		return account_->setProperty( name.right( name.length() - 8 ), value );
	}
	else
	{
		Q_INT16 skillId = Skills::instance()->findSkillByDef( name );
		if ( skillId != -1 )
		{
			setSkillValue( skillId, value.toInt() );
			if ( socket_ )
				socket_->sendSkill( skillId );
			return 0;
		}
	}

	return cBaseChar::setProperty( name, value );
}
示例#21
0
SharedPtr<Character> CharacterFactory::make(const String& pCharacterName, SharedPtr<Account> pAccount) {
	if (!pAccount) return false;

	auto character = std::make_shared<Character>();

	// Associate Account.
	character->setAccount(pAccount);

	// Associate Experience::Controller.
	auto expController = new Experience::Controller();
	character->setExperienceController(expController);

	if (!mDataStore->characterLoad(pCharacterName, character.get())) {
		mLog->error("Failed to load Character: " + pCharacterName);
		return nullptr;
	}

	//// Check: Data::Character loaded.
	////auto characterData = new Data::Character();
	//if (!mDataStore->characterLoad(pCharacterName, characterData)) {
	//	mLog->error("Failed to load data for Character: " + pCharacterName);
	//	delete characterData;
	//	return nullptr;
	//}

	// Create and initialise Inventory.
	auto inventory = std::make_shared<Inventory>();
	character->setInventory(inventory);
	// Load Inventory.

	auto taskController = std::make_shared<TaskController>();
	character->setTaskController(taskController);
	// Load Tasks.

	// Load Buffs.

	// Load Skills

	// Load Languages

	// Load Spell Book

	// Load Spell Bar

	// Load Disciplines

	// Load AA

	//if (!inventory->initialise(&characterData->mInventory, mItemFactory, mLogFactory, pCharacterName)) {
	//	mLog->error("Failed to initialise Inventory for Character: " + pCharacterName);
	//	return nullptr;
	//}

	// Create and initialise Experience::Controller.
	//auto experienceController = new Experience::Controller();
	//if (!experienceController->onLoad(&characterData->mExperience)) {
	//	mLog->error("Failed to initialise Experience::Controller for Character: " + pCharacterName);
	//	delete inventory;
	//	delete characterData;
	//	delete experienceController;
	//	return nullptr;
	//}

	//auto character = new Character(characterData);

	//// Create and initialise TaskController.
	//auto taskController = new TaskController();
	//if (!taskController->initialise(character, mTaskDataStore, mLogFactory)) {
	//	// TODO: Delete
	//	return false;
	//}
	//if (!taskController->onLoad(characterData->mCompletedTasks)) {
	//	// TODO: Delete.
	//	return false;
	//}

	//// Initialise Character.
	//if (!character->initialise(pAccount, inventory, experienceController, taskController)) {
	//	mLog->error("Failed to initialise Character: " + pCharacterName);
	//	delete inventory;
	//	delete characterData;
	//	delete experienceController;
	//	delete character;
	//	return nullptr;
	//}

	// Check: Is this the first time the Character has logged in.
	if (character->isNew()) {
		//mLog->info("")
	}

	return character;
}
Kopete::Account *skypeEditAccount::apply() {
	kDebug(SKYPE_DEBUG_GLOBAL);

	//first, I need a pointer to that account
	if (!account()) //it does not exist
		setAccount(new SkypeAccount(d->protocol, "Skype" ));//create a new one
	SkypeAccount *skype = static_cast<SkypeAccount *>(account());//get the account

	//set it's values
	skype->setExcludeConnect(widget->excludeCheck->isChecked());//Save the "exclude from connection" setup

	if ( widget->LaunchNeverRadio->isChecked() )//get the type how to launch skype
		skype->launchType = 1;
	else if ( widget->LaunchNeededRadio->isChecked() )
		skype->launchType = 0;

	if (widget->AuthorCheck->isChecked())
		skype->author = widget->AuthorEdit->text();//put there what user wrote
	else
		skype->author = "";//nothing unusual

	skype->setHitchHike(widget->HitchCheck->isChecked());//save the hitch hike mode and activat ethe new value
	skype->setMarkRead(widget->MarkCheck->isChecked());//set the mark read messages mode and activate it
	skype->setScanForUnread(widget->ScanCheck->isChecked());
	skype->setCallControl(widget->CallCheck->isChecked());
	skype->setPings(widget->PingsCheck->isChecked());

	if ( widget->radioButton4->isChecked() )
		skype->setBus(0);
	else if ( widget->radioButton5->isChecked() )
		skype->setBus(1);

	skype->setLaunchTimeout(widget->LaunchSpin->value());
	skype->setSkypeCommand(widget->CommandEdit->text());
	skype->setWaitBeforeConnect(widget->WaitSpin->value());
	skype->setLeaveOnExit(!widget->LeaveCheck->isChecked());
	if (widget->AutoCloseCallCheck->isChecked()) {
		skype->setCloseWindowTimeout(widget->CloseTimeoutSpin->value());
	} else {
		skype->setCloseWindowTimeout(0);
	}
	if (widget->StartCallCommandCheck->isChecked()) {
		skype->setStartCallCommand(widget->StartCallCommandEdit->text());
	} else {
		skype->setStartCallCommand("");
	}
	skype->setWaitForStartCallCommand(widget->WaitForStartCallCommandCheck->isChecked());
	if (widget->EndCallCommandCheck->isChecked()) {
		skype->setEndCallCommand(widget->EndCallCommandEdit->text());
	} else {
		skype->setEndCallCommand("");
	}
	if (widget->IncomingCommandCheck->isChecked()) {
		skype->setIncomingCommand(widget->IncomingCommandEdit->text());
	} else {
		skype->setIncomingCommand("");
	}

	skype->setEndCallCommandOnlyForLast(widget->OnlyLastCallCommandCheck->isChecked());
	skype->save();//save it to config
	return skype;//return the account
}
示例#23
0
void qipinfium::loadMessages(const QString &path)
{
	QDir dir = path;
	if(!dir.cd("History"))
		return;
	QHash<QString,QString> protocols;
	protocols[QLatin1String("icq")]    = QLatin1String("ICQ");
	protocols[QLatin1String("jabber")] = QLatin1String("Jabber");
	protocols[QLatin1String("mra")]    = QLatin1String("MRIM");
	QStringList filters;
	foreach(QString format,protocols.keys())
		filters << (format + QLatin1String("*.qhf")) << (format + QLatin1String("*.ahf"));
	QFileInfoList files = dir.entryInfoList(filters, QDir::Files);
	setMaxValue(files.size());
	for(int i = 0; i < files.size(); i++)
	{
		setValue(i + 1);
		QString protocol = files[i].fileName().section("_",0,0);
		while(!protocol.isEmpty() && protocol.at(protocol.length() - 1).isDigit())
			protocol.chop(1);
		protocol = protocols[protocol.toLower()];
		if(protocol.isEmpty())
		{
			warning() << "Unknown protocol: " << files[i].fileName();
			continue;
		}
		setProtocol(protocol);
		setAccount(m_accounts.value(protocol));
		QFile file(files[i].absoluteFilePath());
		if(file.open(QFile::ReadOnly))
		{
			QByteArray bytearray = file.readAll();
			const uchar *data = (const uchar *)bytearray.constData();
			const uchar *end = data + bytearray.size();
			if(memcmp(data, "QHF", 3))
				continue;
			uchar version = data[3];
			data += 44;
			QString uin = getString(data, getUInt16(data));
			QString name = getString(data, getUInt16(data));
			Q_UNUSED(name);
			QDateTime time;
			setContact(uin);
			while(data < end)
			{
				quint16 type = getUInt16(data);
				quint32 index = getUInt32(data);
				data += 2;
				if(type == 1)
				{
					Message message;
					data += 10;
					time = QDateTime::fromTime_t(getUInt32(data));
					time.setTimeSpec(Qt::LocalTime);
					if(version == 1)
						time = time.toUTC().addDays(2);
					else
						time = time.toUTC();
					message.setTime(time);
					data += 4;
					message.setIncoming(getUInt8(data) == 0);
					data += 4;
					int mes_len = version == 3 ? getUInt32(data) : getUInt16(data);
					message.setText(getString(data, mes_len, version > 1));
					appendMessage(message);
				}
				else
					data += index;
			}
		}
	}
}
示例#24
0
bool
epUser::init(const std::string& account, const std::string& passwd) {
        setAccount(account);
        setPasswd(passwd);
        return true;
}