コード例 #1
0
/**
	Checks whether ParamSegment contains valid characters in 
	Parameter name and Parameter value as specified in RFC 3261.
							
	@param		aName	The descriptor for parameter name to be checked as per RFC 3261.
	@param		aValue	The descriptor for value to be checked as per RFC 3261.
	@return		A boolean value of ETrue if uri contains valid parameters and values,
				EFalse if it does not.
*/
TBool TValidatorSip::IsValidParamSegment(const TDesC8& aName, const TDesC8& aValue) const
	{
	if (!aName.Length() || !IsValidParam(aName) ) 
		{
		return EFalse;	
		}
	
	/**************************************************************************************************************
	* As per RFC 3261 if the uri-parameter contains name as Tranport or User or Method then its Value must be     *
	* the characters as specified in Token. else if the name is Ttl then its value must lie in between 0 - 255.   *
	* else if the name is Maddr then its value must be a host, else if the name is lr then it must not conatin    *
	* any value, else it must be a other-parameter whose value must conatin the characters specified in paramchar.*
	* As per INC 115503 and due to IOP issue Validation of lr paramater is not performed.						  *
	***************************************************************************************************************/
	if ( ( (aName.CompareF(KTransport()) == 0 || aName.CompareF(KUser()) == 0 || aName.CompareF(KMethod()) == 0 ) 	
	   	   	  && !IsValidParamToken(aValue) )
		|| ( aName.CompareF(KTtl()) == 0 && !IsValidParamTtl(aValue) )
		|| ( aName.CompareF(KMaddr()) == 0  && !IsValidParamMaddr(aValue) )
		|| ( aName.CompareF(KTransport()) != 0 && aName.CompareF(KUser()) != 0 && aName.CompareF(KMethod()) != 0 && aName.CompareF(KTtl()) != 0 
			&& aName.CompareF(KMaddr()) != 0 && aName.CompareF(KLr()) != 0 && !IsValidParam(aValue))
		)
		{
		return EFalse;	
		}

	return ETrue;
	}
コード例 #2
0
ファイル: kwrited.cpp プロジェクト: Fat-Zer/tdebase
KWrited::KWrited() : TQTextEdit()
{
  int pref_width, pref_height;

  setFont(TDEGlobalSettings::fixedFont());
  pref_width = (2 * TDEGlobalSettings::desktopGeometry(0).width()) / 3;
  pref_height = fontMetrics().lineSpacing() * 10;
  setMinimumWidth(pref_width);
  setMinimumHeight(pref_height);
  setReadOnly(true);
  setFocusPolicy(TQ_NoFocus);
  setWordWrap(TQTextEdit::WidgetWidth);
  setTextFormat(TQt::PlainText);

  pty = new KPty();
  pty->open();
  pty->login(KUser().loginName().local8Bit().data(), getenv("DISPLAY"));
  TQSocketNotifier *sn = new TQSocketNotifier(pty->masterFd(), TQSocketNotifier::Read, TQT_TQOBJECT(this));
  connect(sn, TQT_SIGNAL(activated(int)), this, TQT_SLOT(block_in(int)));

  TQString txt = i18n("KWrited - Listening on Device %1").arg(pty->ttyName());
  setCaption(txt);
  
  kdDebug() << txt << endl;
}
コード例 #3
0
void KFileShare::readConfig() // static
{
    // Create KFileSharePrivate instance
    KFileSharePrivate::self();
    KSimpleConfig config(QString::fromLatin1(FILESHARECONF), true);

    s_sharingEnabled = config.readEntry("FILESHARING", "yes") == "yes";
    s_restricted = config.readEntry("RESTRICT", "yes") == "yes";
    s_fileShareGroup = config.readEntry("FILESHAREGROUP", "fileshare");


    if(!s_sharingEnabled)
        s_authorization = UserNotAllowed;
    else if(!s_restricted)
        s_authorization = Authorized;
    else
    {
        // check if current user is in fileshare group
        KUserGroup shareGroup(s_fileShareGroup);
        if(shareGroup.users().findIndex(KUser()) > -1)
            s_authorization = Authorized;
        else
            s_authorization = UserNotAllowed;
    }

    if(config.readEntry("SHARINGMODE", "simple") == "simple")
        s_shareMode = Simple;
    else
        s_shareMode = Advanced;


    s_sambaEnabled = config.readEntry("SAMBA", "yes") == "yes";
    s_nfsEnabled = config.readEntry("NFS", "yes") == "yes";
}
コード例 #4
0
ファイル: chatwindow.cpp プロジェクト: KDE/konversation
void ChatWindow::cdIntoLogPath()
{
    QString home = KUser(KUser::UseRealUserID).homeDir();
    QUrl logUrl = Preferences::self()->logfilePath();

    if(!logUrl.isLocalFile())
    {
        return;
    }

    QString logPath = logUrl.toLocalFile();

    QDir logDir(home);

    // Try to "cd" into the logfile path.
    if (!logDir.cd(logPath))
    {
        // Only create log path if logging is enabled.
        if (log())
        {
            // Try to create the logfile path and "cd" into it again.
            logDir.mkpath(logPath);
            logDir.cd(logPath);
        }
    }

    // Add the logfile name to the path.
    logfile.setFileName(logDir.path() + '/' + logName);
}
コード例 #5
0
ファイル: kuser_unix.cpp プロジェクト: mathieusab/kcoreaddons
QList<KUser> KUserGroup::users(uint maxCount) const
{
    QList<KUser> result;
    listGroupMembers(d->gid, maxCount, [&](const passwd *p) {
        result.append(KUser(p));
    });
    return result;
}
コード例 #6
0
ファイル: kuser_unix.cpp プロジェクト: crayonink/calligra-2
 void fillGroup(const ::group *p) {
     if (p) {
         gid = p->gr_gid;
         name = QString::fromLocal8Bit(p->gr_name);
         for (char **user = p->gr_mem; *user; user++)
             users.append(KUser(*user));
     }
 }
コード例 #7
0
ファイル: tdmshutdown.cpp プロジェクト: Fat-Zer/tdebase
TDMCancelShutdown::TDMCancelShutdown( int how, int start, int timeout,
                                      int force, int uid, const char *os,
                                      TQWidget *_parent )
	: inherited( -1, _parent )
{
	if (force == SHUT_FORCE) {
		if (_allowNuke == SHUT_NONE)
			mayOk = false;
		else if (_allowNuke == SHUT_ROOT)
			mayNuke = doesNuke = true;
	}
	TQLabel *lab = new TQLabel( mayOk ?
	                          i18n("Abort pending shutdown:") :
	                          i18n("No permission to abort pending shutdown:"),
	                          this );
	box->addWidget( lab );
	TQDateTime qdt;
	TQString strt, end;
	if (start < time( 0 ))
		strt = i18n("now");
	else {
		qdt.setTime_t( start );
		strt = qdt.toString( Qt::LocalDate );
	}
	if (timeout == TO_INF)
		end = i18n("infinite");
	else {
		qdt.setTime_t( timeout );
		end = qdt.toString( Qt::LocalDate );
	}
	TQString trg =
		i18n("Owner: %1"
		     "\nType: %2%5"
		     "\nStart: %3"
		     "\nTimeout: %4")
		.arg( uid == -2 ?
		      i18n("console user") :
		      uid == -1 ?
		      i18n("control socket") :
		      KUser( uid ).loginName() )
		.arg( how == SHUT_HALT ?
		      i18n("turn off computer") :
		      i18n("restart computer") )
		.arg( strt ).arg( end )
		.arg( os ?
		      i18n("\nNext boot: %1").arg( TQString::fromLocal8Bit( os ) ) :
		      TQString() );
	if (timeout != TO_INF)
		trg += i18n("\nAfter timeout: %1")
		       .arg( force == SHUT_FORCE ?
		             i18n("abort all sessions") :
		             force == SHUT_FORCEMY ?
		             i18n("abort own sessions") :
		             i18n("cancel shutdown") );
	lab = new TQLabel( trg, this );
	box->addWidget( lab );
	complete( 0 );
}
コード例 #8
0
ファイル: kdepasswd.cpp プロジェクト: blue-shell/folderview
int main(int argc, char **argv)
{
    KAboutData aboutData("kdepasswd", 0, ki18n("KDE passwd"),
            KDE_VERSION_STRING, ki18n("Changes a UNIX password."),
            KAboutData::License_Artistic, ki18n("Copyright (c) 2000 Geert Jansen"));
    aboutData.addAuthor(ki18n("Geert Jansen"), ki18n("Maintainer"),
            "*****@*****.**");
    aboutData.setProgramIconName( "preferences-desktop-user-password" );

    KCmdLineArgs::init(argc, argv, &aboutData);

    KCmdLineOptions options;
    options.add("+[user]", ki18n("Change password of this user"));
    KCmdLineArgs::addCmdLineOptions(options);
    KUniqueApplication::addCmdLineOptions();


    if (!KUniqueApplication::start()) {
        kDebug() << "kdepasswd is already running";
        return 2;
    }

    KUniqueApplication app;

    KUser ku;
    QString user;
    bool bRoot = ku.isSuperUser();
    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

    if (args->count())
        user = args->arg(0);

    /* You must be able to run "kdepasswd loginName" */
    if ( !user.isEmpty() && user!=KUser().loginName() && !bRoot)
    {
        KMessageBox::sorry(0, i18n("You need to be root to change the password of other users."));
        return 1;
    }

    QByteArray oldpass;
    if (!bRoot)
    {
        int result = KDEpasswd1Dialog::getPassword(oldpass);
        if (result != KDEpasswd1Dialog::Accepted)
            return 1;
    }

    KDEpasswd2Dialog *dlg = new KDEpasswd2Dialog(oldpass, user.toLocal8Bit());


    dlg->exec();
    if (dlg->result() == KDEpasswd2Dialog::Rejected)
        return 1;

    return 0;
}
コード例 #9
0
ファイル: kmimetypetest.cpp プロジェクト: KDE/kdelibs4support
void KMimeTypeTest::testIcons()
{
    if (!KUser().isSuperUser()) { // Can't test this one if running as root
        QString emptyString; // gcc-3.3 workaround
        QTemporaryDir tmp(emptyString);
        QFile(tmp.path()).setPermissions(0);
        tmp.setAutoRemove(true);
        //KUrl url( tmp.path() );
        //QCOMPARE(KIO::iconNameForUrl(url), "inode-directory"); // was folder_locked, but we don't have that anymore - TODO
        QFile(tmp.path()).setPermissions(QFile::ReadOwner | QFile::ExeOwner); // so we can 'rm -rf' it
    }
}
コード例 #10
0
ファイル: kfileitem.cpp プロジェクト: KDE/kio
void KFileItemPrivate::init()
{
    m_access.clear();
    //  metaInfo = KFileMetaInfo();

    // stat() local files if needed
    // TODO: delay this until requested
    if (m_fileMode == KFileItem::Unknown || m_permissions == KFileItem::Unknown || m_entry.count() == 0) {
        if (m_url.isLocalFile()) {
            /* directories may not have a slash at the end if
             * we want to stat() them; it requires that we
             * change into it .. which may not be allowed
             * stat("/is/unaccessible")  -> rwx------
             * stat("/is/unaccessible/") -> EPERM            H.Z.
             * This is the reason for the StripTrailingSlash
             */
            QT_STATBUF buf;
            const QString path = m_url.adjusted(QUrl::StripTrailingSlash).toLocalFile();
            const QByteArray pathBA = QFile::encodeName(path);
            if (QT_LSTAT(pathBA.constData(), &buf) == 0) {
                m_entry.insert(KIO::UDSEntry::UDS_DEVICE_ID,           buf.st_dev);
                m_entry.insert(KIO::UDSEntry::UDS_INODE,               buf.st_ino);

                mode_t mode = buf.st_mode;
                if ((buf.st_mode & QT_STAT_MASK) == QT_STAT_LNK) {
                    m_bLink = true;
                    if (QT_STAT(pathBA, &buf) == 0) {
                        mode = buf.st_mode;
                    } else {// link pointing to nowhere (see FileProtocol::createUDSEntry() in ioslaves/file/file.cpp)
                        mode = (QT_STAT_MASK - 1) | S_IRWXU | S_IRWXG | S_IRWXO;
                    }
                }
                m_entry.insert(KIO::UDSEntry::UDS_SIZE,      buf.st_size);
                m_entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, buf.st_mode & QT_STAT_MASK); // extract file type
                m_entry.insert(KIO::UDSEntry::UDS_ACCESS,    buf.st_mode & 07777); // extract permissions
                m_entry.insert(KIO::UDSEntry::UDS_MODIFICATION_TIME,   buf.st_mtime); // TODO: we could use msecs too...
                m_entry.insert(KIO::UDSEntry::UDS_ACCESS_TIME,         buf.st_atime);
#ifndef Q_OS_WIN
                m_entry.insert(KIO::UDSEntry::UDS_USER,                KUser(buf.st_uid).loginName());
                m_entry.insert(KIO::UDSEntry::UDS_GROUP,               KUserGroup(buf.st_gid).name());
#endif

                // TODO: these can be removed, we can use UDS_FILE_TYPE and UDS_ACCESS everywhere
                if (m_fileMode == KFileItem::Unknown) {
                    m_fileMode = mode & QT_STAT_MASK; // extract file type
                }
                if (m_permissions == KFileItem::Unknown) {
                    m_permissions = mode & 07777; // extract permissions
                }
            }
        }
    }
}
コード例 #11
0
ファイル: kuser_unix.cpp プロジェクト: crayonink/calligra-2
QList<KUser> KUser::allUsers() {
  QList<KUser> result;

  passwd* p;

  while ((p = getpwent()))  {
    result.append(KUser(p));
  }

  endpwent();

  return result;
}
コード例 #12
0
ファイル: kmimetypetest.cpp プロジェクト: vasi/kdelibs
void KMimeTypeTest::testIcons()
{
    checkIcon( KUrl( "file:/tmp/" ), "inode-directory" );

    if ( !KUser().isSuperUser() ) // Can't test this one if running as root
    {
        QString emptyString; // gcc-3.3 workaround
        KTempDir tmp( emptyString, 0 );
        tmp.setAutoRemove( true );
        KUrl url( tmp.name() );
        checkIcon( url, "inode-directory" ); // was folder_locked, but we don't have that anymore - TODO
        KDE::chmod( tmp.name(), 0500 ); // so we can 'rm -rf' it
    }
}
コード例 #13
0
ファイル: kuser_unix.cpp プロジェクト: mathieusab/kcoreaddons
QList<KUser> KUser::allUsers(uint maxCount)
{
    QList<KUser> result;

    passwd *p;
    setpwent();

    for (uint i = 0; i < maxCount && (p = getpwent()); ++i) {
        result.append(KUser(p));
    }

    endpwent();

    return result;
}
コード例 #14
0
ファイル: kuserproxy.cpp プロジェクト: KDE/kdeclarative
void KUserProxy::update(const QString &path)
{
    if (path == m_user.faceIconPath()) {
        // we need to force updates, even when the path doesn't change,
        // but the underlying image does. Change path temporarily, to
        // make the Image reload.
        // Needs cache: false in the Image item to actually reload
        m_temporaryEmptyFaceIconPath = true;
        emit faceIconUrlChanged();
        m_temporaryEmptyFaceIconPath = false;
        emit faceIconUrlChanged();
    } else if (path == etcPasswd) {
        m_user = KUser();
        emit nameChanged();
    }
}
コード例 #15
0
ファイル: smb4kcustomoptions.cpp プロジェクト: KDE/smb4k
Smb4KCustomOptions::Smb4KCustomOptions()
: d(new Smb4KCustomOptionsPrivate)
{
  d->type           = UnknownNetworkItem;
  d->remount        = UndefinedRemount;
  d->smbPort        = 139;
#if defined(Q_OS_LINUX)
  d->fileSystemPort = 445;
  d->securityMode   = UndefinedSecurityMode;
  d->writeAccess    = UndefinedWriteAccess;
#endif
  d->kerberos       = UndefinedKerberos;
  d->user           = KUser(KUser::UseRealUserID);
  d->group          = KUserGroup(KUser::UseRealUserID);
  d->wol_first_scan = false;
  d->wol_mount      = false;
}
コード例 #16
0
ファイル: smb4kcustomoptions.cpp プロジェクト: KDE/smb4k
Smb4KCustomOptions::Smb4KCustomOptions(Smb4KHost *host)
: d(new Smb4KCustomOptionsPrivate)
{
  d->workgroup      = host->workgroupName();
  d->url            = host->url();
  d->type           = Host;
  d->remount        = UndefinedRemount;
  d->smbPort        = host->port() != -1 ? host->port() : 139;
#if defined(Q_OS_LINUX)
  d->fileSystemPort = 445;
  d->securityMode   = UndefinedSecurityMode;
  d->writeAccess    = UndefinedWriteAccess;
#endif
  d->kerberos       = UndefinedKerberos;
  d->user           = KUser(KUser::UseRealUserID);
  d->group          = KUserGroup(KUser::UseRealUserID);
  d->ip.setAddress(host->ip());
  d->wol_first_scan = false;
  d->wol_mount      = false;
}
コード例 #17
0
ファイル: kfileplacesmodel.cpp プロジェクト: vasi/kdelibs
KFilePlacesModel::KFilePlacesModel(QObject *parent)
    : QAbstractItemModel(parent), d(new Private(this))
{
    const QString file = KStandardDirs::locateLocal("data", "kfileplaces/bookmarks.xml");
    d->bookmarkManager = KBookmarkManager::managerForFile(file, "kfilePlaces");

    // Let's put some places in there if it's empty. We have a corner case here:
    // Given you have bookmarked some folders (which have been saved on
    // ~/.local/share/user-places.xbel (according to freedesktop bookmarks spec), and
    // deleted the home directory ~/.kde, the call managerForFile() will return the
    // bookmark manager for the fallback "kfilePlaces", making root.first().isNull() being
    // false (you have your own items bookmarked), resulting on only being added your own
    // bookmarks, and not the default ones too. So, we also check if kfileplaces/bookmarks.xml
    // file exists, and if it doesn't, we also add the default places. (ereslibre)
    KBookmarkGroup root = d->bookmarkManager->root();
    if (root.first().isNull() || !QFile::exists(file)) {

        // NOTE: The context for these I18N_NOOP2 calls has to be "KFile System Bookmarks".
        // The real i18nc call is made later, with this context, so the two must match.
        //
        // createSystemBookmark actually does nothing with its third argument,
        // but we have to give it something so the I18N_NOOP2 calls stay here for now.
        //
        // (coles, 13th May 2009)

        KFilePlacesItem::createSystemBookmark(d->bookmarkManager,
                                              "Home", I18N_NOOP2("KFile System Bookmarks", "Home"),
                                              KUrl(KUser().homeDir()), "user-home");
        KFilePlacesItem::createSystemBookmark(d->bookmarkManager,
                                              "Network", I18N_NOOP2("KFile System Bookmarks", "Network"),
                                              KUrl("remote:/"), "network-workgroup");
#ifdef Q_OS_WIN
        // adding drives
        foreach ( const QFileInfo& info, QDir::drives() ) {
#ifndef _WIN32_WCE
            uint type = DRIVE_UNKNOWN;
#endif
            QString driveIcon = "drive-harddisk";
#ifndef _WIN32_WCE
            QT_WA({ type = GetDriveTypeW((wchar_t *)info.absoluteFilePath().utf16()); },
                  { type = GetDriveTypeA(info.absoluteFilePath().toLocal8Bit()); });
コード例 #18
0
void KCGlobal::init()
{
  char buf[256];
  buf[0] = '\0';
  if (!gethostname(buf, sizeof(buf)))
    buf[sizeof(buf)-1] ='\0';
  QString hostname(buf);
  
  setHostName(hostname);
  setUserName(KUser().loginName());
  setRoot(getuid() == 0);

  setKDEVersion(KDE::versionString());

  struct utsname info;
  uname(&info);

  setSystemName(info.sysname);
  setSystemRelease(info.release);
  setSystemVersion(info.version);
  setSystemMachine(info.machine);
}
コード例 #19
0
ファイル: handler.cpp プロジェクト: JosephMillsAtWork/u2t
void Handler::addAndActivateConnection(const QString& device, const QString& specificObject, const QString& password)
{
    NetworkManager::AccessPoint::Ptr ap;
    NetworkManager::WirelessDevice::Ptr wifiDev;
    Q_FOREACH (const NetworkManager::Device::Ptr & dev, NetworkManager::networkInterfaces()) {
        if (dev->type() == NetworkManager::Device::Wifi) {
            wifiDev = dev.objectCast<NetworkManager::WirelessDevice>();
            ap = wifiDev->findAccessPoint(specificObject);
            if (ap) {
                break;
            }
        }
    }

    if (!ap) {
        return;
    }

    NetworkManager::ConnectionSettings::Ptr settings = NetworkManager::ConnectionSettings::Ptr(new NetworkManager::ConnectionSettings(NetworkManager::ConnectionSettings::Wireless));
    settings->setId(ap->ssid());
    settings->setUuid(NetworkManager::ConnectionSettings::createNewUuid());
    settings->setAutoconnect(true);
#if 0
    settings->addToPermissions(KUser().loginName(), QString());
#endif

    NetworkManager::WirelessSetting::Ptr wifiSetting = settings->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
    wifiSetting->setInitialized(true);
    wifiSetting = settings->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
    wifiSetting->setSsid(ap->ssid().toUtf8());
    if (ap->mode() == NetworkManager::AccessPoint::Adhoc) {
        wifiSetting->setMode(NetworkManager::WirelessSetting::Adhoc);
    }
    NetworkManager::WirelessSecuritySetting::Ptr wifiSecurity = settings->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();

    NetworkManager::WirelessSecurityType securityType = NetworkManager::findBestWirelessSecurity(wifiDev->wirelessCapabilities(), true, (ap->mode() == NetworkManager::AccessPoint::Adhoc), ap->capabilities(), ap->wpaFlags(), ap->rsnFlags());

    if (securityType != NetworkManager::NoneSecurity) {
        wifiSecurity->setInitialized(true);
        wifiSetting->setSecurity("802-11-wireless-security");
    }

    if (securityType == NetworkManager::Leap ||
        securityType == NetworkManager::DynamicWep ||
        securityType == NetworkManager::Wpa2Eap ||
        securityType == NetworkManager::WpaEap) {
        if (securityType == NetworkManager::DynamicWep || securityType == NetworkManager::Leap) {
            wifiSecurity->setKeyMgmt(NetworkManager::WirelessSecuritySetting::Ieee8021x);
            if (securityType == NetworkManager::Leap) {
                wifiSecurity->setAuthAlg(NetworkManager::WirelessSecuritySetting::Leap);
            }
        } else {
            wifiSecurity->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaEap);
        }
        m_tmpConnectionUuid = settings->uuid();
        m_tmpDevicePath = device;
        m_tmpSpecificPath = specificObject;

#if 0
        QPointer<ConnectionDetailEditor> editor = new ConnectionDetailEditor(settings, true);
        editor->show();
        KWindowSystem::setState(editor->winId(), NET::KeepAbove);
        KWindowSystem::forceActiveWindow(editor->winId());
        connect(editor.data(), &ConnectionDetailEditor::accepted,
                [editor, this] () {
                    addConnection(editor->setting());
                });
        connect(editor.data(), &ConnectionDetailEditor::finished,
                [editor] () {
                    if (editor) {
                        editor->deleteLater();
                    }
                });
        editor->setModal(true);
        editor->show();
#endif
    } else {
        if (securityType == NetworkManager::StaticWep) {
            wifiSecurity->setKeyMgmt(NetworkManager::WirelessSecuritySetting::Wep);
            wifiSecurity->setWepKey0(password);
#if 0
            if (KWallet::Wallet::isEnabled()) {
                wifiSecurity->setWepKeyFlags(NetworkManager::Setting::AgentOwned);
            }
#endif
        } else {
            if (ap->mode() == NetworkManager::AccessPoint::Adhoc) {
                wifiSecurity->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaNone);
            } else {
                wifiSecurity->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaPsk);
            }
            wifiSecurity->setPsk(password);
#if 0
            if (KWallet::Wallet::isEnabled()) {
                wifiSecurity->setPskFlags(NetworkManager::Setting::AgentOwned);
            }
#endif
        }
        QDBusPendingReply<QDBusObjectPath> reply = NetworkManager::addAndActivateConnection(settings->toMap(), device, specificObject);
        QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
        watcher->setProperty("action", Handler::AddAndActivateConnection);
        watcher->setProperty("connection", settings->name());
        connect(watcher, &QDBusPendingCallWatcher::finished, this, &Handler::replyFinished);
    }

    settings.clear();
}
コード例 #20
0
ファイル: kuser_unix.cpp プロジェクト: crayonink/calligra-2
KUserGroup::KUserGroup(KUser::UIDMode mode)
{
    d = new Private(getgrgid(KUser(mode).gid()));
}
コード例 #21
0
KCModule * KCModuleProxy::realModule() const
{

	/*
	 * Note, don't call any function that calls realModule() since
	 * that leads to an infinite loop.
	 */

	kdDebug(711) << k_funcinfo << endl;

	/* Already loaded */
	if( d->kcm )
		return d->kcm;

	/* /We/ have no kcm, but kcmshell running with root prevs does.. */
	if( d->rootMode )
		return 0;

	QApplication::setOverrideCursor( Qt::WaitCursor );
	
	KCModuleProxy * that = const_cast<KCModuleProxy*>( this );

	if( !d->isInitialized )
	{
  		d->dcopName = moduleInfo().handle().prepend("KCModuleProxy-").utf8();
		d->topLayout = new QVBoxLayout( that, 0, 0, "topLayout" );

		d->isInitialized = true;
	}

	if( !d->dcopClient )
		d->dcopClient = new DCOPClient();

	if( !d->dcopClient->isRegistered() )
  		d->dcopClient->registerAs( d->dcopName, false );

	d->dcopClient->setAcceptCalls( true );

	if( d->dcopClient->appId() == d->dcopName || d->bogusOccupier )
	{ /* We got the name we requested, because no one was before us, 
	   * or, it was an random application which had picked that name */
		kdDebug(711) << "Module not already loaded, loading module" << endl;

		d->dcopObject = new KCModuleProxyIfaceImpl( d->dcopName, that );

		d->kcm = KCModuleLoader::loadModule( moduleInfo(), KCModuleLoader::Inline, d->withFallback,
			that, name(), d->args );

		connect( d->kcm, SIGNAL( changed( bool ) ),
				SLOT(moduleChanged(bool)) );
		connect( d->kcm, SIGNAL( destroyed() ),
				SLOT( moduleDestroyed() ) );
		connect( d->kcm, SIGNAL(quickHelpChanged()), 
				SIGNAL(quickHelpChanged()));
		QWhatsThis::add( that, d->kcm->quickHelp() );

		d->topLayout->addWidget( d->kcm );

		if ( !d->rootInfo && /* If it's already done */
				moduleInfo().needsRootPrivileges() /* root, anyone? */ && 
				!KUser().isSuperUser() ) /* Not necessary if we're root */
		{

			d->rootInfo = new QLabel( that, "rootInfo" );
			d->topLayout->insertWidget( 0, d->rootInfo );

			d->rootInfo->setFrameShape(QFrame::Box);
			d->rootInfo->setFrameShadow(QFrame::Raised);

			const QString msg = d->kcm->rootOnlyMsg();
			if( msg.isEmpty() )
				d->rootInfo->setText(i18n(
   					  "<b>Changes in this section requires root access.</b><br />"
					  "Click the \"Administrator Mode\" button to "
					  "allow modifications."));
			else
				d->rootInfo->setText(msg);

			QWhatsThis::add( d->rootInfo, i18n(
				  "This section requires special permissions, probably "
				  "for system-wide changes; therefore, it is "
				  "required that you provide the root password to be "
				  "able to change the module's properties. If "
				  "you do not provide the password, the module will be "
				  "disabled."));
		}
	}
コード例 #22
0
KClassicGreeter::KClassicGreeter( KGreeterPluginHandler *_handler,
                                  KdmThemer *themer,
                                  QWidget *parent, QWidget *pred,
                                  const QString &_fixedEntity,
                                  Function _func, Context _ctx ) :
	QObject(),
	KGreeterPlugin( _handler ),
	fixedUser( _fixedEntity ),
	func( _func ),
	ctx( _ctx ),
	exp( -1 ),
	pExp( -1 ),
	running( false )
{
	KdmItem *user_entry = 0, *pw_entry = 0;
	QGridLayout *grid = 0;
	int line = 0;

	layoutItem = 0;

	if (themer &&
	    (!(user_entry = themer->findNode( "user-entry" )) ||
	     !(pw_entry = themer->findNode( "pw-entry" ))))
		themer = 0;

	if (!themer)
		layoutItem = grid = new QGridLayout( 0, 0, 10 );

	loginLabel = passwdLabel = passwd1Label = passwd2Label = 0;
	loginEdit = 0;
	passwdEdit = passwd1Edit = passwd2Edit = 0;
	if (ctx == ExUnlock || ctx == ExChangeTok)
		fixedUser = KUser().loginName();
	if (func != ChAuthTok) {
		if (fixedUser.isEmpty()) {
			loginEdit = new KLineEdit( parent );
			loginEdit->setContextMenuEnabled( false );
			connect( loginEdit, SIGNAL(lostFocus()), SLOT(slotLoginLostFocus()) );
			connect( loginEdit, SIGNAL(lostFocus()), SLOT(slotActivity()) );
			connect( loginEdit, SIGNAL(textChanged( const QString & )), SLOT(slotActivity()) );
			connect( loginEdit, SIGNAL(selectionChanged()), SLOT(slotActivity()) );
			if (pred) {
				parent->setTabOrder( pred, loginEdit );
				pred = loginEdit;
			}
			if (!grid) {
				loginEdit->adjustSize();
				user_entry->setWidget( loginEdit );
			} else {
				loginLabel = new QLabel( loginEdit, i18n("&Username:"******"Username:"******"&Password:"******"Current &password:"******"&New password:"******"Con&firm password:"), parent );
		if (pred) {
			parent->setTabOrder( pred, passwd1Edit );
			parent->setTabOrder( passwd1Edit, passwd2Edit );
		}
		if (grid) {
			grid->addWidget( passwd1Label, line, 0 );
			grid->addWidget( passwd1Edit, line++, 1 );
			grid->addWidget( passwd2Label, line, 0 );
			grid->addWidget( passwd2Edit, line, 1 );
		}
		if (!passwdEdit)
			passwd1Edit->setFocus();
	}
}
コード例 #23
0
#include <KConfig>
#include <KFileItem>
#include <KConfigGroup>
#include <KSharedConfig>
#include <KLocalizedString>

#include <baloo/indexerconfig.h>
#include <baloo/query.h>

#define COMPACT_LEVEL   2

#define CONFIG_BACK_DAYS           QStringLiteral("BackDays")
#define CONFIG_BACK_DAYS_DEFAULT   7

static const QString HomeDir = KUser().homeDir();
static const int HomeDirLength = HomeDir.length();

RecentFolders::RecentFolders(const QByteArray &pool, const QByteArray &app)
    : SlaveBase("recentfolders", pool, app), backDays(CONFIG_BACK_DAYS_DEFAULT)
{
    loadConfig();
}

RecentFolders::~RecentFolders()
{
}

void RecentFolders::loadConfig()
{
    KSharedConfig::Ptr config = KSharedConfig::openConfig(QStringLiteral("kio_recentfolders"));
コード例 #24
0
bool DccTransferRecv::queue()
{
    kdDebug() << "DccTransferRecv::queue()" << endl;

    if ( getStatus() != Configuring )
        return false;

    if ( m_partnerIp.isEmpty() || m_partnerPort.isEmpty() )
        return false;

    if (!kapp->authorize("allow_downloading"))
    {
        //note we have this after the initialisations so that item looks okay
        //Do not have the rights to send the file.  Shouldn't have gotten this far anyway
        failed(i18n("The admin has restricted the right to receive files"));
        return false;
    }

    // check if the sender IP is valid
    if ( m_partnerIp == "0.0.0.0" )
    {
        failed( i18n( "Invalid sender address (%1)" ).arg( m_partnerIp ) );
        return false;
    }

    // TODO: should we support it?
    if ( m_fileSize == 0 )
    {
        failed( i18n( "Unsupported negotiation (filesize=0)" ) );
        return false;
    }

    if ( m_fileName.isEmpty() )
    {
        m_fileName = "unnamed_file";
    }

    if ( m_fileURL.isEmpty() )
    {
        // determine default incoming file URL

        // set default folder
        if ( !Preferences::dccPath().isEmpty() )
            m_fileURL = KURL( Preferences::dccPath() );
        else
            m_fileURL.setPath( KUser( KUser::UseRealUserID ).homeDir() );  // default folder is *not* specified

        // add a slash if there is none
        m_fileURL.adjustPath( 1 );

        // Append folder with partner's name if wanted
        if ( Preferences::dccCreateFolder() )
            m_fileURL.addPath( m_partnerNick + '/' );

        // Just incase anyone tries to do anything nasty
        QString fileNameSanitized = sanitizeFileName( m_fileName );

        // Append partner's name to file name if wanted
        if ( Preferences::dccAddPartner() )
            m_fileURL.addPath( m_partnerNick + '.' + fileNameSanitized );
        else
            m_fileURL.addPath( fileNameSanitized );
    }

    return DccTransfer::queue();
}
コード例 #25
0
ファイル: smb4kcustomoptions.cpp プロジェクト: KDE/smb4k
bool Smb4KCustomOptions::isEmpty()
{
  // Type
  if (d->type != UnknownNetworkItem)
  {
    return false;
  }
  else
  {
    // Do nothing
  }
  
  // Profile
  if (!d->profile.isEmpty())
  {
    return false;
  }
  else
  {
    // Do nothing
  }
  
  // Workgroup
  if (!d->workgroup.isEmpty())
  {
    return false;
  }
  else
  {
    // Do nothing
  }
  
  // URL
  if (!d->url.isEmpty())
  {
    return false;
  }
  else
  {
    // Do nothing
  }
  
  // IP address
  if (!d->ip.isNull())
  {
    return false;
  }
  else
  {
    // Do nothing
  }
  
  // Remounting
  if (d->remount != Smb4KCustomOptions::UndefinedRemount)
  {
    return false;
  }
  else
  {
    // Do nothing
  }

  // SMB port
  if (d->smbPort != 139)
  {
    return false;
  }
  else
  {
    // Do nothing
  }
  
#if defined(Q_OS_LINUX)
  // File system port (used for mounting)
  if (d->fileSystemPort != 445)
  {
    return false;
  }
  else
  {
    // Do nothing
  }
  
  // Security mode
  if (d->securityMode != Smb4KCustomOptions::UndefinedSecurityMode)
  {
    return false;
  }
  else
  {
    // Do nothing
  }

  // Write access
  if (d->writeAccess != UndefinedWriteAccess)
  {
    return false;
  }
  else
  {
    // Do nothing
  }
#endif

  // Kerberos
  if (d->kerberos != UndefinedKerberos)
  {
    return false;
  }
  else
  {
    // Do nothing
  }
  
  // UID
  if (d->user.userId() != KUser(KUser::UseRealUserID).userId())
  {
    return false;
  }
  else
  {
    // Do nothing
  }
  
  // GID
  if (d->group.groupId() != KUserGroup(KUser::UseRealUserID).groupId())
  {
    return false;
  }
  else
  {
    // Do nothing
  }
  
  // MAC address
  if (!d->mac.isNull())
  {
    return false;
  }
  else
  {
    // Do nothing
  }
  
  // Send WOL packages before first scan
  if (d->wol_first_scan)
  {
    return false;
  }
  else
  {
    // Do nothing
  }
  
  // Send WOL packages before mount
  if (d->wol_mount)
  {
    return false;
  }
  else
  {
    // Do nothing
  }
  
  return true;
}