本文整理汇总了C++中QDBusError::errorString方法的典型用法代码示例。如果您正苦于以下问题:C++ QDBusError::errorString方法的具体用法?C++ QDBusError::errorString怎么用?C++ QDBusError::errorString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDBusError
的用法示例。
在下文中一共展示了QDBusError::errorString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: qWarning
/*!
Finds a user by \a userName.
Sync blocking API.
\param userName The user name to look up.
\return the corresponding UserAccount object.
*/
UserAccount *AccountsManager::findUserByName(const QString &userName)
{
Q_D(AccountsManager);
QDBusPendingReply<QDBusObjectPath> reply = d->interface->FindUserByName(userName);
reply.waitForFinished();
if (reply.isError()) {
QDBusError error = reply.error();
qWarning("Couldn't find user by user name %s: %s",
userName.toUtf8().constData(),
error.errorString(error.type()).toUtf8().constData());
return 0;
}
QDBusObjectPath path = reply.argumentAt<0>();
if (path.path().isEmpty())
return Q_NULLPTR;
UserAccount *account = d->usersCache.value(path.path(), Q_NULLPTR);
if (!account) {
account = new UserAccount(path.path(), d->interface->connection());
d->usersCache[path.path()] = account;
}
return account;
}
示例2: listCachedUsersAsync
/*!
Cached a list of user accounts.
Async unblocking API.
*/
void AccountsManager::listCachedUsersAsync()
{
Q_D(AccountsManager);
QDBusPendingCall call = d->interface->ListCachedUsers();
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
connect(watcher, &QDBusPendingCallWatcher::finished, this, [=](QDBusPendingCallWatcher *w) {
QDBusPendingReply< QList<QDBusObjectPath> > reply = *w;
w->deleteLater();
if (reply.isError()) {
QDBusError error = reply.error();
qWarning("Couldn't list cached users: %s",
error.errorString(error.type()).toUtf8().constData());
} else {
UserAccountList userList;
QList<QDBusObjectPath> value = reply.argumentAt<0>();
userList.reserve(value.size());
for (int i = 0; i < value.size(); i++) {
const QString path = value.at(i).path();
UserAccount *account = d->usersCache.value(path, Q_NULLPTR);
if (!account) {
account = new UserAccount(path, d->interface->connection());
d->usersCache[path] = account;
}
userList.append(account);
}
Q_EMIT listCachedUsersFinished(userList);
}
});
}
示例3: listCachedUsers
/*!
Returns a list of user accounts.
\param systemUsers If true, returns also system users.
*/
UserAccountList AccountsManager::listCachedUsers()
{
Q_D(AccountsManager);
UserAccountList list;
QDBusPendingReply< QList<QDBusObjectPath> > reply = d->interface->ListCachedUsers();
reply.waitForFinished();
if (reply.isError()) {
QDBusError error = reply.error();
qWarning("Couldn't list cached users: %s",
error.errorString(error.type()).toUtf8().constData());
return list;
}
QList<QDBusObjectPath> value = reply.argumentAt<0>();
list.reserve(value.size());
for (int i = 0; i < value.size(); i++) {
const QString path = value.at(i).path();
UserAccount *account = d->usersCache.value(path, Q_NULLPTR);
if (!account) {
account = new UserAccount(path, d->interface->connection());
d->usersCache[path] = account;
}
list.append(account);
}
return list;
}
示例4: userCached
/*!
Caches a user account, so that it shows up in listCachedUsers() output.
The user name may be a remote user, but the system must be able to lookup
the user name and resolve the user information.
A userCached() signal with a UserAccount pointer will be emitted as soon
as the user account has been cached by AccountsService.
\param userName The user name for the user.
*/
void AccountsManager::cacheUser(const QString &userName)
{
Q_D(AccountsManager);
QDBusPendingCall call = d->interface->CacheUser(userName);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
connect(watcher, &QDBusPendingCallWatcher::finished, this, [=](QDBusPendingCallWatcher *w) {
QDBusPendingReply<QDBusObjectPath> reply = *w;
w->deleteLater();
if (reply.isError()) {
QDBusError error = reply.error();
qWarning("Couldn't cache user %s: %s",
userName.toUtf8().constData(),
error.errorString(error.type()).toUtf8().constData());
} else {
QDBusObjectPath path = reply.argumentAt<0>();
if (path.path().isEmpty())
return;
UserAccount *account = d->usersCache.value(path.path(), Q_NULLPTR);
if (!account) {
account = new UserAccount(path.path(), d->interface->connection());
d->usersCache[path.path()] = account;
}
Q_EMIT userCached(account);
}
});
}
示例5: deleteUser
/*!
Deletes the user designated by \a uid.
\param uid The user identifier.
\param removeFiles If true all files owned by the user will be removed.
\return whether the user was deleted successfully.
*/
bool AccountsManager::deleteUser(uid_t uid, bool removeFiles)
{
Q_D(AccountsManager);
QDBusPendingReply<> reply = d->interface->DeleteUser(uid, removeFiles);
if (reply.isError()) {
QDBusError error = reply.error();
qWarning("Couldn't delete user %d: %s", uid,
error.errorString(error.type()).toUtf8().constData());
return false;
}
return true;
}
示例6: createUser
/*!
Creates a new \a accountType type user account whose name is \a userName,
real name is \a fullName.
\param userName The name of the new user to be created.
\param fullName First name and last name.
\param accountType The account type.
\return whether the user was created successfully.
*/
bool AccountsManager::createUser(const QString &userName,
const QString &fullName,
UserAccount::AccountType accountType)
{
Q_D(AccountsManager);
QDBusPendingReply<QDBusObjectPath> reply = d->interface->CreateUser(userName, fullName, accountType);
if (reply.isError()) {
QDBusError error = reply.error();
qWarning("Couldn't create user %s: %s", userName.toUtf8().constData(),
error.errorString(error.type()).toUtf8().constData());
return false;
}
return true;
}
示例7: findUserByNameAsync
/*!
Finds a user by user \a userName
Async unblocking API
\param userName The user name to look up.
*/
void AccountsManager::findUserByNameAsync(const QString &userName)
{
Q_D(AccountsManager);
QDBusPendingCall call = d->interface->FindUserByName(userName);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
connect(watcher, &QDBusPendingCallWatcher::finished, this, [=](QDBusPendingCallWatcher *w) {
QDBusPendingReply<QDBusObjectPath> reply = *w;
w->deleteLater();
if (reply.isError()) {
QDBusError error = reply.error();
qWarning("Couldn't find user by name %s: %s",
userName.toUtf8().constData(),
error.errorString(error.type()).toUtf8().constData());
} else {
QDBusObjectPath path = reply.argumentAt<0>();
if (!path.path().isEmpty())
Q_EMIT userFound(new UserAccount(path.path(), d->interface->connection()));
}
});
}