Changeset View
Changeset View
Standalone View
Standalone View
krfb/invitationsrfbserver.cpp
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | 47 | i18n("%1@%2 (shared desktop)", | |||
---|---|---|---|---|---|
48 | KUser().loginName(), | 48 | KUser().loginName(), | ||
49 | QHostInfo::localHostName()), | 49 | QHostInfo::localHostName()), | ||
50 | "_rfb._tcp", | 50 | "_rfb._tcp", | ||
51 | KrfbConfig::port()); | 51 | KrfbConfig::port()); | ||
52 | instance->setListeningAddress("0.0.0.0"); | 52 | instance->setListeningAddress("0.0.0.0"); | ||
53 | instance->setListeningPort(KrfbConfig::port()); | 53 | instance->setListeningPort(KrfbConfig::port()); | ||
54 | instance->setPasswordRequired(true); | 54 | instance->setPasswordRequired(true); | ||
55 | 55 | | |||
56 | instance->m_wallet = nullptr; | ||||
56 | if (KrfbConfig::noWallet()) { | 57 | if (KrfbConfig::noWallet()) { | ||
57 | instance->walletOpened(false); | 58 | instance->walletOpened(false); | ||
58 | } | 59 | } else { | ||
59 | else { | 60 | instance->openKWallet(); | ||
60 | instance->m_wallet = Wallet::openWallet( | | |||
61 | Wallet::NetworkWallet(), 0, Wallet::Asynchronous); | | |||
62 | if(instance->m_wallet) { | | |||
63 | connect(instance->m_wallet, &KWallet::Wallet::walletOpened, | | |||
64 | instance, &InvitationsRfbServer::walletOpened); | | |||
65 | } | | |||
66 | } | 61 | } | ||
67 | } | 62 | } | ||
68 | 63 | | |||
69 | const QString& InvitationsRfbServer::desktopPassword() const | 64 | const QString& InvitationsRfbServer::desktopPassword() const | ||
70 | { | 65 | { | ||
71 | return m_desktopPassword; | 66 | return m_desktopPassword; | ||
72 | } | 67 | } | ||
73 | 68 | | |||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | 112 | { | |||
120 | KConfigGroup krfbConfig(KSharedConfig::openConfig(),"Security"); | 115 | KConfigGroup krfbConfig(KSharedConfig::openConfig(),"Security"); | ||
121 | m_allowUnattendedAccess = krfbConfig.readEntry( | 116 | m_allowUnattendedAccess = krfbConfig.readEntry( | ||
122 | "allowUnattendedAccess", QVariant(false)).toBool(); | 117 | "allowUnattendedAccess", QVariant(false)).toBool(); | ||
123 | } | 118 | } | ||
124 | 119 | | |||
125 | InvitationsRfbServer::~InvitationsRfbServer() | 120 | InvitationsRfbServer::~InvitationsRfbServer() | ||
126 | { | 121 | { | ||
127 | stop(); | 122 | stop(); | ||
123 | | ||||
128 | KConfigGroup krfbConfig(KSharedConfig::openConfig(),"Security"); | 124 | KConfigGroup krfbConfig(KSharedConfig::openConfig(), "Security"); | ||
129 | krfbConfig.writeEntry("allowUnattendedAccess",m_allowUnattendedAccess); | 125 | krfbConfig.writeEntry("allowUnattendedAccess", m_allowUnattendedAccess); | ||
130 | if(!KrfbConfig::noWallet()) { | | |||
131 | if (m_wallet && m_wallet->isOpen()) { | | |||
132 | if( (m_wallet->currentFolder()=="krfb") || | | |||
133 | ((m_wallet->hasFolder("krfb") || m_wallet->createFolder("krfb")) && | | |||
134 | m_wallet->setFolder("krfb")) ) { | | |||
135 | | ||||
136 | m_wallet->writePassword("desktopSharingPassword",m_desktopPassword); | | |||
137 | m_wallet->writePassword("unattendedAccessPassword",m_unattendedPassword); | | |||
138 | } | | |||
139 | } | | |||
140 | 126 | | |||
127 | if (!KrfbConfig::noWallet() && m_wallet) { | ||||
128 | closeKWallet(); | ||||
141 | } else { | 129 | } else { | ||
142 | krfbConfig.writeEntry("desktopPassword", | 130 | krfbConfig.writeEntry("desktopPassword", | ||
143 | KStringHandler::obscure(m_desktopPassword)); | 131 | KStringHandler::obscure(m_desktopPassword)); | ||
144 | krfbConfig.writeEntry("unattendedPassword", | 132 | krfbConfig.writeEntry("unattendedPassword", | ||
145 | KStringHandler::obscure(m_unattendedPassword)); | 133 | KStringHandler::obscure(m_unattendedPassword)); | ||
146 | krfbConfig.writeEntry("allowUnattendedAccess", | 134 | krfbConfig.writeEntry("allowUnattendedAccess", | ||
147 | m_allowUnattendedAccess); | 135 | m_allowUnattendedAccess); | ||
148 | } | 136 | } | ||
149 | } | 137 | } | ||
150 | 138 | | |||
151 | PendingRfbClient* InvitationsRfbServer::newClient(rfbClientPtr client) | 139 | PendingRfbClient* InvitationsRfbServer::newClient(rfbClientPtr client) | ||
152 | { | 140 | { | ||
153 | return new PendingInvitationsRfbClient(client, this); | 141 | return new PendingInvitationsRfbClient(client, this); | ||
154 | } | 142 | } | ||
155 | 143 | | |||
144 | void InvitationsRfbServer::openKWallet() | ||||
145 | { | ||||
146 | m_wallet = Wallet::openWallet(Wallet::NetworkWallet(), 0, Wallet::Asynchronous); | ||||
147 | if (m_wallet) { | ||||
148 | connect(instance->m_wallet, &KWallet::Wallet::walletOpened, | ||||
149 | this, &InvitationsRfbServer::walletOpened); | ||||
150 | } | ||||
151 | } | ||||
152 | | ||||
153 | void InvitationsRfbServer::closeKWallet() | ||||
154 | { | ||||
155 | if (m_wallet && m_wallet->isOpen()) { | ||||
156 | if ((m_wallet->currentFolder() == "krfb") || | ||||
157 | ((m_wallet->hasFolder("krfb") || m_wallet->createFolder("krfb")) && | ||||
158 | m_wallet->setFolder("krfb")) ) { | ||||
159 | m_wallet->writePassword("desktopSharingPassword", m_desktopPassword); | ||||
160 | m_wallet->writePassword("unattendedAccessPassword", m_unattendedPassword); | ||||
161 | } | ||||
162 | delete m_wallet; // closes the wallet | ||||
163 | m_wallet = nullptr; | ||||
164 | } | ||||
165 | } | ||||
166 | | ||||
156 | void InvitationsRfbServer::walletOpened(bool opened) | 167 | void InvitationsRfbServer::walletOpened(bool opened) | ||
157 | { | 168 | { | ||
158 | QString desktopPassword; | 169 | QString desktopPassword; | ||
159 | QString unattendedPassword; | 170 | QString unattendedPassword; | ||
160 | Q_ASSERT(m_wallet); | 171 | Q_ASSERT(m_wallet); | ||
161 | if( opened && | 172 | if( opened && | ||
162 | ( m_wallet->hasFolder("krfb") || m_wallet->createFolder("krfb") ) && | 173 | ( m_wallet->hasFolder("krfb") || m_wallet->createFolder("krfb") ) && | ||
163 | m_wallet->setFolder("krfb") ) { | 174 | m_wallet->setFolder("krfb") ) { | ||
▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines |