Changeset View
Changeset View
Standalone View
Standalone View
src/plugins/KDEFrameworksIntegration/kwalletpasswordbackend.cpp
Show First 20 Lines • Show All 75 Lines • ▼ Show 20 Line(s) | 75 | { | |||
---|---|---|---|---|---|
76 | initialize(); | 76 | initialize(); | ||
77 | 77 | | |||
78 | return m_allEntries; | 78 | return m_allEntries; | ||
79 | } | 79 | } | ||
80 | 80 | | |||
81 | void KWalletPasswordBackend::addEntry(const PasswordEntry &entry) | 81 | void KWalletPasswordBackend::addEntry(const PasswordEntry &entry) | ||
82 | { | 82 | { | ||
83 | initialize(); | 83 | initialize(); | ||
84 | 84 | | |||
SGOrava: The should be a space after the if and before the block start
```
if (condition) {
//something… | |||||
85 | if (!m_wallet) { | ||||
86 | return; | ||||
87 | } | ||||
88 | | ||||
85 | PasswordEntry stored = entry; | 89 | PasswordEntry stored = entry; | ||
86 | stored.id = QString("%1/%2").arg(entry.host, entry.username); | 90 | stored.id = QString("%1/%2").arg(entry.host, entry.username); | ||
87 | stored.updated = QDateTime::currentDateTime().toTime_t(); | 91 | stored.updated = QDateTime::currentDateTime().toTime_t(); | ||
There is no need to check again here because this should always be true when the code gets here. SGOrava: There is no need to check again here because this should always be true when the code gets here. | |||||
SGOrava: empty line would be best, no need for spaces. | |||||
88 | 92 | | |||
SGOrava: Kepp the newline here.
It makes it easier to read. | |||||
89 | m_wallet->writeEntry(stored.id.toString(), encodeEntry(stored)); | 93 | m_wallet->writeEntry(stored.id.toString(), encodeEntry(stored)); | ||
90 | m_allEntries.append(stored); | 94 | m_allEntries.append(stored); | ||
91 | } | 95 | } | ||
92 | 96 | | |||
93 | bool KWalletPasswordBackend::updateEntry(const PasswordEntry &entry) | 97 | bool KWalletPasswordBackend::updateEntry(const PasswordEntry &entry) | ||
94 | { | 98 | { | ||
95 | initialize(); | 99 | initialize(); | ||
96 | 100 | | |||
101 | if (!m_wallet) { | ||||
No reason for this warning. Also I think it would be just better to change the initialize to bool initialize() and then check everywhere if (!initialize()) { return; } drosca: No reason for this warning.
Also I think it would be just better to change the `initialize` to… | |||||
102 | return false; | ||||
103 | } | ||||
104 | | ||||
97 | m_wallet->removeEntry(entry.id.toString()); | 105 | m_wallet->removeEntry(entry.id.toString()); | ||
98 | m_wallet->writeEntry(entry.id.toString(), encodeEntry(entry)); | 106 | m_wallet->writeEntry(entry.id.toString(), encodeEntry(entry)); | ||
99 | 107 | | |||
100 | int index = m_allEntries.indexOf(entry); | 108 | int index = m_allEntries.indexOf(entry); | ||
101 | 109 | | |||
102 | if (index > -1) { | 110 | if (index > -1) { | ||
103 | m_allEntries[index] = entry; | 111 | m_allEntries[index] = entry; | ||
104 | } | 112 | } | ||
105 | 113 | | |||
106 | return true; | 114 | return true; | ||
107 | } | 115 | } | ||
108 | 116 | | |||
109 | void KWalletPasswordBackend::updateLastUsed(PasswordEntry &entry) | 117 | void KWalletPasswordBackend::updateLastUsed(PasswordEntry &entry) | ||
110 | { | 118 | { | ||
111 | initialize(); | 119 | initialize(); | ||
112 | 120 | | |||
121 | if (!m_wallet) { | ||||
122 | return; | ||||
123 | } | ||||
124 | | ||||
113 | m_wallet->removeEntry(entry.id.toString()); | 125 | m_wallet->removeEntry(entry.id.toString()); | ||
114 | 126 | | |||
115 | entry.updated = QDateTime::currentDateTime().toTime_t(); | 127 | entry.updated = QDateTime::currentDateTime().toTime_t(); | ||
116 | 128 | | |||
117 | m_wallet->writeEntry(entry.id.toString(), encodeEntry(entry)); | 129 | m_wallet->writeEntry(entry.id.toString(), encodeEntry(entry)); | ||
118 | 130 | | |||
119 | int index = m_allEntries.indexOf(entry); | 131 | int index = m_allEntries.indexOf(entry); | ||
120 | 132 | | |||
121 | if (index > -1) { | 133 | if (index > -1) { | ||
122 | m_allEntries[index] = entry; | 134 | m_allEntries[index] = entry; | ||
123 | } | 135 | } | ||
124 | } | 136 | } | ||
125 | 137 | | |||
126 | void KWalletPasswordBackend::removeEntry(const PasswordEntry &entry) | 138 | void KWalletPasswordBackend::removeEntry(const PasswordEntry &entry) | ||
127 | { | 139 | { | ||
128 | initialize(); | 140 | initialize(); | ||
129 | 141 | | |||
142 | if (!m_wallet) { | ||||
143 | return; | ||||
144 | } | ||||
145 | | ||||
130 | m_wallet->removeEntry(entry.id.toString()); | 146 | m_wallet->removeEntry(entry.id.toString()); | ||
131 | 147 | | |||
132 | int index = m_allEntries.indexOf(entry); | 148 | int index = m_allEntries.indexOf(entry); | ||
133 | 149 | | |||
134 | if (index > -1) { | 150 | if (index > -1) { | ||
135 | m_allEntries.remove(index); | 151 | m_allEntries.remove(index); | ||
136 | } | 152 | } | ||
137 | } | 153 | } | ||
138 | 154 | | |||
139 | void KWalletPasswordBackend::removeAll() | 155 | void KWalletPasswordBackend::removeAll() | ||
140 | { | 156 | { | ||
141 | initialize(); | 157 | initialize(); | ||
142 | 158 | | |||
159 | if (!m_wallet) { | ||||
160 | return; | ||||
161 | } | ||||
162 | | ||||
143 | m_allEntries.clear(); | 163 | m_allEntries.clear(); | ||
144 | 164 | | |||
145 | m_wallet->removeFolder("Falkon"); | 165 | m_wallet->removeFolder("Falkon"); | ||
146 | m_wallet->createFolder("Falkon"); | 166 | m_wallet->createFolder("Falkon"); | ||
147 | } | 167 | } | ||
148 | 168 | | |||
149 | void KWalletPasswordBackend::initialize() | 169 | void KWalletPasswordBackend::initialize() | ||
150 | { | 170 | { | ||
▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines |
The should be a space after the if and before the block start