本文整理汇总了C++中KUser类的典型用法代码示例。如果您正苦于以下问题:C++ KUser类的具体用法?C++ KUser怎么用?C++ KUser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KUser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CheckUser
bool KUser::CheckUser(unsigned long ip,unsigned gid)
{
KUser_int_map::iterator it;
m_lock.Lock();
it=m_user.find(ip);
if(it!=m_user.end()){
if(gid==ALLUSER||gid==(*it).second.user_id){
// printf("gid==0 or gid == loginid\n");
goto done;
}
for(int i=0;i<(*it).second.gids->size();i++){
if(gid==(*it).second.gids->operator[](i)){
// printf("loginid in group gid.\n");
goto done;
}
}
}
m_lock.Unlock();
return false;
done:
(*it).second.last_active_time=time(NULL);
m_lock.Unlock();
return true;
}
示例2: KDialog
UploadDialog::UploadDialog(/*Engine *engine,*/ QWidget *parent) :
KDialog(parent)
{
m_entry = NULL;
// popuplate dialog with stuff
QWidget* _mainWidget = new QWidget(this);
setMainWidget(_mainWidget);
setupUi(_mainWidget);
setCaption(i18n("Share Hot New Stuff"));
setButtons(Ok | Cancel);
setDefaultButton(Cancel);
setModal(false);
mTitleWidget->setText(i18nc("Program name followed by 'Add On Uploader'",
"%1 Add-On Uploader",
KGlobal::activeComponent().aboutData()->programName()));
mTitleWidget->setPixmap(KIcon(KGlobal::activeComponent().aboutData()->programIconName()));
QStringList languagecodes = KGlobal::locale()->languageList();
for (int i = 0; i < languagecodes.count(); i++) {
QString languagecode = languagecodes.at(i);
QString language = KGlobal::locale()->languageCodeToName(languagecode);
mLanguageCombo->addItem(language);
m_languages.insert(language, languagecode);
}
KUser user;
mAuthorEdit->setText(user.property(KUser::FullName).toString());
connect(this, SIGNAL(okClicked()), this, SLOT(slotOk()));
}
示例3: testRootUser
void SelfTestDialog::testRootUser()
{
KUser user;
if ( user.isSuperUser() ) {
report( Error, ki18n( "Akonadi was started as root" ), ki18n( "Running Internet-facing applications as root/administrator exposes you to many security risks. MySQL, used by this Akonadi installation, will not allow itself to run as root, to protect you from these risks." ) );
} else {
report( Success, ki18n( "Akonadi is not running as root" ), ki18n( "Akonadi is not running as a root/administrator user, which is the recommended setup for a secure system." ) );
}
}
示例4: main
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"),
"[email protected]");
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;
}
示例5: main
//===================Main function=================
int main(int argc, char* argv)
{
int buf_len;
char main_buffer[MAX_MAIN_BUFFER];
KConnectionManager::Initialize();
KConnectionManager km = KConnectionManager();
KConnection* main_con = km.create_con(MAIN_PORT);
KLobby lobby = KLobby(&km);
//Handle signal
signal(SIGINT, TerminalHandler);
//Debug memory leak
#ifdef MEMORY_LEAK
_CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_WNDW );
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif//MEMORY_LEAK
sockaddr remote_addr;
while(Running) {//MainLoop
km.check(1,0);
if (main_con->has_data()) {
//Reinitialize buffer and len
buf_len = MAX_MAIN_BUFFER;
memset(main_buffer, 0, sizeof(main_buffer));
memset(&remote_addr, 0, sizeof(remote_addr));
//Recv data
buf_len = main_con->recv_data(main_buffer, buf_len, false);
main_con->get_raddr(&remote_addr);
if (strncmp("PING", main_buffer, MAX_MAIN_BUFFER) == 0) {//Echo message
//TODO:Send "PONG"
}
else if (strncmp("HELLO", main_buffer, 5) == 0) {
if (strncmp("0.83", main_buffer + 5, MAX_MAIN_BUFFER - 5) == 0) {
//XXX:Rember to delete user and game at list
KUser* nuser = lobby.new_user();
__PRINT("Port:%d\n", nuser->get_port());
snprintf(main_buffer, MAX_MAIN_BUFFER, "HELLOD00D%i", nuser->get_port());
main_con->send(main_buffer,sizeof(main_buffer));
}
else {
//Version error
//TODO:Send "VER"
}
}
else {
printf("Got an unexcept data:%s", main_buffer);
}
__PRINT("Recvdata:%s\n", main_buffer);
}
lobby.tick();
}
km.Release();
return 0;
}
示例6: CheckLogin
bool KUser::CheckLogin(const char *user)
{
KUser_int_map::iterator it;
m_lock.Lock();
for(it=m_user.begin();it!=m_user.end();it++){
if((*it).second.user->user==user){
m_lock.Unlock();
return true;
}
}
m_lock.Unlock();
return false;
}
示例7: findUserByID
/*
根据ID寻找用户
*/
KUser* KLobby::findUserByID(unsigned short id)
{
KList<KUser*>::iterator it = m_userlist.begin();
KUser* result = NULL;
KListNode<KUser*>* p_node;
while ((p_node = it.next()) !=0) {
result = p_node->m_data;
if (result->GetID() == id) {
break;
}
}
return result;
}
示例8: SaveAll
void KUser::SaveAll()
{
unsigned stay_time=0;
KUser_int_map::iterator it;
int now_time=time(NULL);
m_lock.Lock();
for(it=m_user.begin();it!=m_user.end();it++){
(*it).second.user->total_time+=now_time-(*it).second.login_time;
}
m_lock.Unlock();
Save();
}
示例9: QGraphicsWidget
SessionWidget::SessionWidget( QGraphicsItem * parent, Qt::WindowFlags wFlags)
: QGraphicsWidget ( parent, wFlags)
{
this->setFocusPolicy(Qt::ClickFocus);
m_signalMapper = new QSignalMapper(this);
QGraphicsLinearLayout* mainLayout = new QGraphicsLinearLayout(Qt::Vertical);
mainLayout->setSpacing(0);
mainLayout->addStretch();
this->setLayout(mainLayout);
connect( m_signalMapper, SIGNAL(mapped(int)),
this, SLOT(slotSwitchSession(int)));
Q_ASSERT(mainLayout->count() == 0);
//Cache the icon pixmaps
QSize iconSize = QSize(KIconLoader::SizeSmallMedium, KIconLoader::SizeSmallMedium);
SessList sessions;
KDisplayManager manager;
manager.localSessions(sessions);
QList<QGraphicsWidget*> entries;
foreach(SessEnt session, sessions) {
QPixmap pixmap;
KUser user (session.user);
if (!user.isValid())
continue;
if (session.tty)
continue;
Plasma::IconWidget* entry = createButton(this);
pixmap = getUserIcon(user);
entry->setIcon(pixmap);
QString username = getUsername(false, user);
entry->setText(username);
connect(entry, SIGNAL(clicked()), m_signalMapper, SLOT(map()));
m_signalMapper->setMapping(entry, session.vt);
if (session.self)
entry->setEnabled(false);
entries << entry;
}
示例10: settings
Settings AddBackupWizard::settings()
{
KUser user;
QString source = user.homeDir();
QString destination = page2->destination();
QString relativeDest = page2->relativeDestination();
QString deviceUDI = page2->deviceUDI();
QStringList excludedDirs = page3->excludedDirs();
QString mountPoint = page2->mountPoint();
Settings settings (source, deviceUDI, relativeDest, excludedDirs);
settings.setMount( mountPoint);
return settings;
}
示例11: time
std::string KUser::ListLoginUser()
{
stringstream s;
int now_time=time(NULL);
// std::vector<std::string> user_list;
s << "<table><tr><td></td><td>user</td><td>from</td><td>stay time(sec)</td><td>inactive time(sec)</td></tr>\n";
KUser_int_map::iterator it;
m_lock.Lock();
for(it=m_user.begin();it!=m_user.end();it++){
s << "<tr><td><a href=/killloginuser?user=" << (*it).second.user->user << ">kill</a></td><td>" << (*it).second.user->user << "</td><td>" << make_ip((*it).first) << "</td><td>" << (now_time-(*it).second.login_time) << "</td><td>" << (now_time-(*it).second.last_active_time) << "</td></tr>\n";
}
// user_list.push_back((*it).second.user);
m_lock.Unlock();
s << "</table>";
return s.str();
}
示例12: ForceLogout
bool KUser::ForceLogout(const char *user,bool use_lock)
{
KUser_int_map::iterator it;
if(use_lock)
m_lock.Lock();
for(it=m_user.begin();it!=m_user.end();it++){
if((*it).second.user->user==user){
(*it).second.user->state=0;
klog(RUN_LOG,"Force logou user %s success\n",(*it).second.user->user.c_str());
m_user.erase(it);
m_lock.Unlock();
return true;
}
}
if(use_lock)
m_lock.Unlock();
return false;
}
示例13: Logout
int KUser::Logout(unsigned long ip)
{
unsigned stay_time=0;
KUser_int_map::iterator it;
m_lock.Lock();
it=m_user.find(ip);
if(it==m_user.end()){
m_lock.Unlock();
return stay_time;
}
stay_time=time(NULL)-(*it).second.login_time;
//m_user.total_time+=stay_time;
(*it).second.user->total_time+=stay_time;
(*it).second.user->state=0;//set the user logout
klog(RUN_LOG,"user %s logout success\n",(*it).second.user->user.c_str());
m_user.erase(it);
m_lock.Unlock();
return stay_time;
}
示例14: while
QStringList PortListener::processServiceTemplate(const QString &a) {
QStringList l;
QValueVector<KInetInterface> v = KInetInterface::getAllInterfaces(false);
QValueVector<KInetInterface>::Iterator it = v.begin();
while (it != v.end()) {
KInetSocketAddress *address = (*(it++)).address();
if (!address)
continue;
QString hostName = address->nodeName();
KUser u;
QString x = a; // replace does not work in const QString. Why??
l.append(x.replace(QRegExp("%h"), KServiceRegistry::encodeAttributeValue(hostName))
.replace(QRegExp("%p"), QString::number(m_port))
.replace(QRegExp("%u"), KServiceRegistry::encodeAttributeValue(u.loginName()))
.replace(QRegExp("%i"), KServiceRegistry::encodeAttributeValue(m_uuid))
.replace(QRegExp("%f"), KServiceRegistry::encodeAttributeValue(u.fullName())));
}
return l;
}
示例15: Login
bool KUser::Login(unsigned long ip,const char *user)
{
UserInfo m_userinfo;
if(!LoadUserInfo(user,m_userinfo))
return false;
LoginUserInfo tmpuser;
stringmap::iterator it2;
KUser_int_map::iterator it;
tmpuser.login_time=time(NULL);
tmpuser.last_active_time=tmpuser.login_time;
//tmpuser.user=user;
m_root_lock.Lock();
it2=m_all_user.find(user);
if(it2==m_all_user.end()){
m_root_lock.Unlock();
return false;
}
(*it2).second->last_ip=ip;
(*it2).second->state=1;//set the user login
(*it2).second->last_time=tmpuser.login_time;
tmpuser.user=(*it2).second;
tmpuser.user_id=(*it2).second->uid;
tmpuser.gids=&(*it2).second->gids;
m_root_lock.Unlock();
if(tmpuser.user_id==0){
klog(ERR_LOG,"user %s user_id is 0,It may be a bug in %s:%d\n",user,__FILE__,__LINE__);
return false;
}
m_lock.Lock();
it=m_user.find(ip);
if(it!=m_user.end())
goto err;
ForceLogout(user,false);
m_user[ip]=tmpuser;
m_lock.Unlock();
char ips[18];
make_ip(ip,ips);
klog(RUN_LOG,"user %s(%d) login from %s success\n",user,tmpuser.user_id,ips);
return true;
err:
m_lock.Unlock();
return false;
}