Exemple #1
0
//
// This function sets the advice for all cookies originating from
// the same domain as _cookie
//
void KCookieJar::setDomainAdvice(KHttpCookiePtr cookiePtr, KCookieAdvice _advice)
{
    QString domain;
    stripDomain(cookiePtr->host(), domain); // We file the cookie under this domain.

    setDomainAdvice(domain, _advice);
}
Exemple #2
0
void KCookieJar::loadConfig(KConfig *_config, bool reparse )
{
    if ( reparse )
        _config->reparseConfiguration();

    _config->setGroup("Cookie Dialog");
    m_showCookieDetails = _config->readBoolEntry( "ShowCookieDetails" );
    m_preferredPolicy = _config->readNumEntry( "PreferredPolicy", 0 );

    _config->setGroup("Cookie Policy");
    QStringList domainSettings = _config->readListEntry("CookieDomainAdvice");
    m_rejectCrossDomainCookies = _config->readBoolEntry( "RejectCrossDomainCookies", true );
    m_autoAcceptSessionCookies = _config->readBoolEntry( "AcceptSessionCookies", true );
    m_ignoreCookieExpirationDate = _config->readBoolEntry( "IgnoreExpirationDate", false );
    QString value = _config->readEntry("CookieGlobalAdvice", L1("Ask"));
    m_globalAdvice = strToAdvice(value);

    // Reset current domain settings first.
    for ( QStringList::Iterator it=m_domainList.begin(); it != m_domainList.end(); )
    {
         // Make sure to update iterator before calling setDomainAdvice()
         // setDomainAdvice() might delete the domain from domainList.
         QString domain = *it++;
         setDomainAdvice(domain, KCookieDunno);
    }

    // Now apply the domain settings read from config file...
    for ( QStringList::Iterator it=domainSettings.begin();
          it != domainSettings.end(); )
    {
        const QString &value = *it++;

        int sepPos = value.findRev(':');

        if (sepPos <= 0)
          continue;

        QString domain(value.left(sepPos));
        KCookieAdvice advice = strToAdvice( value.mid(sepPos + 1) );
        setDomainAdvice(domain, advice);
    }
}
bool KCookieServer::process(const QCString &fun, const QByteArray &data, QCString& replyType, QByteArray &replyData)
{
    static QAsciiDict<int>* fdict = 0;
    if ( !fdict ) {
	fdict = new QAsciiDict<int>( KCookieServer_fhash, TRUE, FALSE );
	for ( int i = 0; KCookieServer_ftable[i][1]; i++ )
	    fdict->insert( KCookieServer_ftable[i][1],  new int( i ) );
    }
    int* fp = fdict->find( fun );
    switch ( fp?*fp:-1) {
    case 0: { // QString findCookies(QString)
	QString arg0;
	QDataStream arg( data, IO_ReadOnly );
	arg >> arg0;
	replyType = KCookieServer_ftable[0][0]; 
	QDataStream _replyStream( replyData, IO_WriteOnly );
	_replyStream << findCookies(arg0 );
    } break;
    case 1: { // QString findCookies(QString,long int)
	QString arg0;
	long int arg1;
	QDataStream arg( data, IO_ReadOnly );
	arg >> arg0;
	arg >> arg1;
	replyType = KCookieServer_ftable[1][0]; 
	QDataStream _replyStream( replyData, IO_WriteOnly );
	_replyStream << findCookies(arg0, arg1 );
    } break;
    case 2: { // QStringList findDomains()
	replyType = KCookieServer_ftable[2][0]; 
	QDataStream _replyStream( replyData, IO_WriteOnly );
	_replyStream << findDomains( );
    } break;
    case 3: { // QStringList findCookies(QValueList<int>,QString,QString,QString,QString)
	QValueList<int> arg0;
	QString arg1;
	QString arg2;
	QString arg3;
	QString arg4;
	QDataStream arg( data, IO_ReadOnly );
	arg >> arg0;
	arg >> arg1;
	arg >> arg2;
	arg >> arg3;
	arg >> arg4;
	replyType = KCookieServer_ftable[3][0]; 
	QDataStream _replyStream( replyData, IO_WriteOnly );
	_replyStream << findCookies(arg0, arg1, arg2, arg3, arg4 );
    } break;
    case 4: { // QString findDOMCookies(QString)
	QString arg0;
	QDataStream arg( data, IO_ReadOnly );
	arg >> arg0;
	replyType = KCookieServer_ftable[4][0]; 
	QDataStream _replyStream( replyData, IO_WriteOnly );
	_replyStream << findDOMCookies(arg0 );
    } break;
    case 5: { // QString findDOMCookies(QString,long int)
	QString arg0;
	long int arg1;
	QDataStream arg( data, IO_ReadOnly );
	arg >> arg0;
	arg >> arg1;
	replyType = KCookieServer_ftable[5][0]; 
	QDataStream _replyStream( replyData, IO_WriteOnly );
	_replyStream << findDOMCookies(arg0, arg1 );
    } break;
    case 6: { // void addCookies(QString,QCString,long int)
	QString arg0;
	QCString arg1;
	long int arg2;
	QDataStream arg( data, IO_ReadOnly );
	arg >> arg0;
	arg >> arg1;
	arg >> arg2;
	replyType = KCookieServer_ftable[6][0]; 
	addCookies(arg0, arg1, arg2 );
    } break;
    case 7: { // void deleteCookie(QString,QString,QString,QString)
	QString arg0;
	QString arg1;
	QString arg2;
	QString arg3;
	QDataStream arg( data, IO_ReadOnly );
	arg >> arg0;
	arg >> arg1;
	arg >> arg2;
	arg >> arg3;
	replyType = KCookieServer_ftable[7][0]; 
	deleteCookie(arg0, arg1, arg2, arg3 );
    } break;
    case 8: { // void deleteCookiesFromDomain(QString)
	QString arg0;
	QDataStream arg( data, IO_ReadOnly );
	arg >> arg0;
	replyType = KCookieServer_ftable[8][0]; 
	deleteCookiesFromDomain(arg0 );
    } break;
    case 9: { // void deleteSessionCookies(long int)
	long int arg0;
	QDataStream arg( data, IO_ReadOnly );
	arg >> arg0;
	replyType = KCookieServer_ftable[9][0]; 
	deleteSessionCookies(arg0 );
    } break;
    case 10: { // void deleteSessionCookiesFor(QString,long int)
	QString arg0;
	long int arg1;
	QDataStream arg( data, IO_ReadOnly );
	arg >> arg0;
	arg >> arg1;
	replyType = KCookieServer_ftable[10][0]; 
	deleteSessionCookiesFor(arg0, arg1 );
    } break;
    case 11: { // void deleteAllCookies()
	replyType = KCookieServer_ftable[11][0]; 
	deleteAllCookies( );
    } break;
    case 12: { // void addDOMCookies(QString,QCString,long int)
	QString arg0;
	QCString arg1;
	long int arg2;
	QDataStream arg( data, IO_ReadOnly );
	arg >> arg0;
	arg >> arg1;
	arg >> arg2;
	replyType = KCookieServer_ftable[12][0]; 
	addDOMCookies(arg0, arg1, arg2 );
    } break;
    case 13: { // void setDomainAdvice(QString,QString)
	QString arg0;
	QString arg1;
	QDataStream arg( data, IO_ReadOnly );
	arg >> arg0;
	arg >> arg1;
	replyType = KCookieServer_ftable[13][0]; 
	setDomainAdvice(arg0, arg1 );
    } break;
    case 14: { // QString getDomainAdvice(QString)
	QString arg0;
	QDataStream arg( data, IO_ReadOnly );
	arg >> arg0;
	replyType = KCookieServer_ftable[14][0]; 
	QDataStream _replyStream( replyData, IO_WriteOnly );
	_replyStream << getDomainAdvice(arg0 );
    } break;
    case 15: { // void reloadPolicy()
	replyType = KCookieServer_ftable[15][0]; 
	reloadPolicy( );
    } break;
    case 16: { // void shutdown()
	replyType = KCookieServer_ftable[16][0]; 
	shutdown( );
    } break;
    default: 
	return KDEDModule::process( fun, data, replyType, replyData );
    }
    return TRUE;
}