author | zautrix <zautrix> | 2005-03-03 15:08:34 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-03 15:08:34 (UTC) |
commit | 9a36b5727a918b73b96fa285c3cff393ec5f43ed (patch) (unidiff) | |
tree | e8740230f22c8a469070c086902c8dc62de1f4c7 | |
parent | a4ea625087ea7213419828e8decdff48ae231968 (diff) | |
download | kdepimpi-9a36b5727a918b73b96fa285c3cff393ec5f43ed.zip kdepimpi-9a36b5727a918b73b96fa285c3cff393ec5f43ed.tar.gz kdepimpi-9a36b5727a918b73b96fa285c3cff393ec5f43ed.tar.bz2 |
nochn fix
-rw-r--r-- | bin/kdepim/pwmanager/germantranslation.txt | 4 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmdoc.cpp | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/bin/kdepim/pwmanager/germantranslation.txt b/bin/kdepim/pwmanager/germantranslation.txt index ccc9d83..2650e28 100644 --- a/bin/kdepim/pwmanager/germantranslation.txt +++ b/bin/kdepim/pwmanager/germantranslation.txt | |||
@@ -1,356 +1,360 @@ | |||
1 | { " Local Time","Ortszeit" }, | 1 | { " Local Time","Ortszeit" }, |
2 | { "Default","Standard" }, | 2 | { "Default","Standard" }, |
3 | { "Configure...","Konfigurieren..." }, | 3 | { "Configure...","Konfigurieren..." }, |
4 | { "Remove sync info","Entferne Sync Info" }, | 4 | { "Remove sync info","Entferne Sync Info" }, |
5 | { "For all profiles","Für alle Profile" }, | 5 | { "For all profiles","Für alle Profile" }, |
6 | { "Enable Pi-Sync","Aktiviere Pi-Sync" }, | 6 | { "Enable Pi-Sync","Aktiviere Pi-Sync" }, |
7 | { "Multiple sync","Multi Sync" }, | 7 | { "Multiple sync","Multi Sync" }, |
8 | { "&Save","&Speichern" }, | 8 | { "&Save","&Speichern" }, |
9 | { "&Print...","Drucken..." }, | 9 | { "&Print...","Drucken..." }, |
10 | { "&File","Datei" }, | 10 | { "&File","Datei" }, |
11 | { "&Edit","Bearbeite" }, | 11 | { "&Edit","Bearbeite" }, |
12 | { "&View","Ansicht" }, | 12 | { "&View","Ansicht" }, |
13 | { "&Help","Hilfe" }, | 13 | { "&Help","Hilfe" }, |
14 | { "Description","Beschreibungen" }, | 14 | { "Description","Beschreibungen" }, |
15 | { "URL","URL" }, | 15 | { "URL","URL" }, |
16 | { "Name:","Name:" }, | 16 | { "Name:","Name:" }, |
17 | { "Documents","Dokumente" }, | 17 | { "Documents","Dokumente" }, |
18 | { "Files","Dateien" }, | 18 | { "Files","Dateien" }, |
19 | { "All Files","Alle Dateien" }, | 19 | { "All Files","Alle Dateien" }, |
20 | { "Name","Name" }, | 20 | { "Name","Name" }, |
21 | { "Size","Größe" }, | 21 | { "Size","Größe" }, |
22 | { "Date","Datum" }, | 22 | { "Date","Datum" }, |
23 | { "Mime Type","Mime Typ" }, | 23 | { "Mime Type","Mime Typ" }, |
24 | { "Ok","Ok" }, | 24 | { "Ok","Ok" }, |
25 | { "Cancel","Abbrechen" }, | 25 | { "Cancel","Abbrechen" }, |
26 | { "1","1" }, | 26 | { "1","1" }, |
27 | { "Synchronization Preferences","Einstellungen der Synchronisationsprofile" }, | 27 | { "Synchronization Preferences","Einstellungen der Synchronisationsprofile" }, |
28 | { "Local device name:","Name dieses Gerätes:" }, | 28 | { "Local device name:","Name dieses Gerätes:" }, |
29 | { "New profile","Neues Profil" }, | 29 | { "New profile","Neues Profil" }, |
30 | { "Clone profile","Klone Profil" }, | 30 | { "Clone profile","Klone Profil" }, |
31 | { "Delete profile","Lösche Profil" }, | 31 | { "Delete profile","Lösche Profil" }, |
32 | { "Profile:","Profil:" }, | 32 | { "Profile:","Profil:" }, |
33 | { "Multiple Sync options","Multi Sync Optionen" }, | 33 | { "Multiple Sync options","Multi Sync Optionen" }, |
34 | { "Include in multiple ","Beziehe in mehrfach " }, | 34 | { "Include in multiple ","Beziehe in mehrfach " }, |
35 | { "calendar ","Kalender " }, | 35 | { "calendar ","Kalender " }, |
36 | { "addressbook ","Adressbuch " }, | 36 | { "addressbook ","Adressbuch " }, |
37 | { "pwmanager","PWmanager" }, | 37 | { "pwmanager","PWmanager" }, |
38 | { " sync"," Sync ein" }, | 38 | { " sync"," Sync ein" }, |
39 | { "Sync algo options","Sync Ablauf Optionen" }, | 39 | { "Sync algo options","Sync Ablauf Optionen" }, |
40 | { "Ask for preferences before sync","Frage nach Synchronisationseinstellungen vor dem Syncen" }, | 40 | { "Ask for preferences before sync","Frage nach Synchronisationseinstellungen vor dem Syncen" }, |
41 | { "Sync preferences","Synchronisations Einstellungen" }, | 41 | { "Sync preferences","Synchronisations Einstellungen" }, |
42 | { "Take local entry on conflict","Nimm lokalen Eintrag beim Konflikt" }, | 42 | { "Take local entry on conflict","Nimm lokalen Eintrag beim Konflikt" }, |
43 | { "Take remote entry on conflict","Nimm fernen Eintrag beim Konflikt" }, | 43 | { "Take remote entry on conflict","Nimm fernen Eintrag beim Konflikt" }, |
44 | { "Take newest entry on conflict","Nimm neuesten Eintrag beim Konflikt" }, | 44 | { "Take newest entry on conflict","Nimm neuesten Eintrag beim Konflikt" }, |
45 | { "Ask for every entry on conflict","Frage bei Konflikten nach" }, | 45 | { "Ask for every entry on conflict","Frage bei Konflikten nach" }, |
46 | { "Force: Take local entry always","Erzwinge: Nimm immer lokalen Eintrag" }, | 46 | { "Force: Take local entry always","Erzwinge: Nimm immer lokalen Eintrag" }, |
47 | { "Force: Take remote entry always","Erzwinge: Nimm immer fernen Eintrag" }, | 47 | { "Force: Take remote entry always","Erzwinge: Nimm immer fernen Eintrag" }, |
48 | { "Show summary after sync","Zeige Zusammenfassung nach dem Synchronisieren" }, | 48 | { "Show summary after sync","Zeige Zusammenfassung nach dem Synchronisieren" }, |
49 | { "Apply filter when adding data to local:","Filter für das Hinzufügen von Daten zu Lokal:" }, | 49 | { "Apply filter when adding data to local:","Filter für das Hinzufügen von Daten zu Lokal:" }, |
50 | { "Incoming calendar filter:","Eingehender Kalender Filter:" }, | 50 | { "Incoming calendar filter:","Eingehender Kalender Filter:" }, |
51 | { "Incoming addressbook filter:","Eingehender Adressbuch Filter:" }, | 51 | { "Incoming addressbook filter:","Eingehender Adressbuch Filter:" }, |
52 | { "Write back synced data","Schreibe gesyncte Daten zurück" }, | 52 | { "Write back synced data","Schreibe gesyncte Daten zurück" }, |
53 | { "Write back options","Optionen zum Zurückschreiben" }, | 53 | { "Write back options","Optionen zum Zurückschreiben" }, |
54 | { "Write back (on remote) existing entries only","Schreibe nur existierende (auf Entfernt) Einträge zurück" }, | 54 | { "Write back (on remote) existing entries only","Schreibe nur existierende (auf Entfernt) Einträge zurück" }, |
55 | { "Apply filter when adding data to remote:","Filter für das Hinzufügen von Daten zu Entfernt:" }, | 55 | { "Apply filter when adding data to remote:","Filter für das Hinzufügen von Daten zu Entfernt:" }, |
56 | { "Outgoing calendar filter:","Ausgehender Kalender Filter:" }, | 56 | { "Outgoing calendar filter:","Ausgehender Kalender Filter:" }, |
57 | { "Outgoing addressbook filter:","Ausgehender Adressbuch Filter:" }, | 57 | { "Outgoing addressbook filter:","Ausgehender Adressbuch Filter:" }, |
58 | { "Write back (calendar) entries for time period only","Schreibe nur Kalender Einträge für Zeitspanne zurück" }, | 58 | { "Write back (calendar) entries for time period only","Schreibe nur Kalender Einträge für Zeitspanne zurück" }, |
59 | { "Time period","Zeitspanne" }, | 59 | { "Time period","Zeitspanne" }, |
60 | { "From ","Von " }, | 60 | { "From ","Von " }, |
61 | { " weeks in the past to "," Wochen in der Vergangenheit bis zu " }, | 61 | { " weeks in the past to "," Wochen in der Vergangenheit bis zu " }, |
62 | { " weeks in the future "," Wochen in der Zukunft " }, | 62 | { " weeks in the future "," Wochen in der Zukunft " }, |
63 | { "Profile kind","Profil Art" }, | 63 | { "Profile kind","Profil Art" }, |
64 | { "Local file","Lokale Datei" }, | 64 | { "Local file","Lokale Datei" }, |
65 | { "Pi-Sync ( direct Kx/Pi to Kx/Pi sync )","Pi-Sync ( direktes Kx/Pi zu Kx/Pi sync )" }, | 65 | { "Pi-Sync ( direct Kx/Pi to Kx/Pi sync )","Pi-Sync ( direktes Kx/Pi zu Kx/Pi sync )" }, |
66 | { "Remote file (w down/upload command)","Entfernte Datei (via down/upload Kommando)" }, | 66 | { "Remote file (w down/upload command)","Entfernte Datei (via down/upload Kommando)" }, |
67 | { "Mobile device (cell phone)","Mobiles Gerät (Handy)" }, | 67 | { "Mobile device (cell phone)","Mobiles Gerät (Handy)" }, |
68 | { "Profile kind specific settings","Profil Art abhängige Einstellungen" }, | 68 | { "Profile kind specific settings","Profil Art abhängige Einstellungen" }, |
69 | { "I/O device: ","I/O device: " }, | 69 | { "I/O device: ","I/O device: " }, |
70 | { "Help...","Hilfe..." }, | 70 | { "Help...","Hilfe..." }, |
71 | { "Connection: ","Connection: " }, | 71 | { "Connection: ","Connection: " }, |
72 | { "Model(opt.): ","Model(opt.): " }, | 72 | { "Model(opt.): ","Model(opt.): " }, |
73 | { "Local file Cal:","Lokale Datei Kal:" }, | 73 | { "Local file Cal:","Lokale Datei Kal:" }, |
74 | { "Local file ABook:","Lokale Datei ABuch:" }, | 74 | { "Local file ABook:","Lokale Datei ABuch:" }, |
75 | { "Local file PWMgr:","Lokale Datei PWMgr:" }, | 75 | { "Local file PWMgr:","Lokale Datei PWMgr:" }, |
76 | { "Choose...","Wähle..." }, | 76 | { "Choose...","Wähle..." }, |
77 | { "Addressbook file (*.vcf) is used by KA/Pi","Adressbuch Datei (*.vcf) wird von KA/Pi genutzt" }, | 77 | { "Addressbook file (*.vcf) is used by KA/Pi","Adressbuch Datei (*.vcf) wird von KA/Pi genutzt" }, |
78 | { "Calendar:","Kalender:" }, | 78 | { "Calendar:","Kalender:" }, |
79 | { "AddressBook:","AdressBuch:" }, | 79 | { "AddressBook:","AdressBuch:" }, |
80 | { "PWManager:","PWManager:" }, | 80 | { "PWManager:","PWManager:" }, |
81 | { "Pre sync (download) command:","Bevor Sync (download) Kommando:" }, | 81 | { "Pre sync (download) command:","Bevor Sync (download) Kommando:" }, |
82 | { "Local temp file:","Lokale temp Datei:" }, | 82 | { "Local temp file:","Lokale temp Datei:" }, |
83 | { "Post sync (upload) command:","Nach Sync (upload) Kommando:" }, | 83 | { "Post sync (upload) command:","Nach Sync (upload) Kommando:" }, |
84 | { "Addressbook file is used by KA/Pi","Adressbuch Datei wird von KA/Pi genutzt" }, | 84 | { "Addressbook file is used by KA/Pi","Adressbuch Datei wird von KA/Pi genutzt" }, |
85 | { "Fill in default values for:","Setze Beispiel Werte ein für:" }, | 85 | { "Fill in default values for:","Setze Beispiel Werte ein für:" }, |
86 | { "ssh/scp","ssh/scp" }, | 86 | { "ssh/scp","ssh/scp" }, |
87 | { "ftp","ftp" }, | 87 | { "ftp","ftp" }, |
88 | { "Hint: Use $PWD$ for placeholder of password!","Hinweis: Benutze $PWD$ als Platzhalter für ein Passwort!" }, | 88 | { "Hint: Use $PWD$ for placeholder of password!","Hinweis: Benutze $PWD$ als Platzhalter für ein Passwort!" }, |
89 | { "Password for remote access: (could be the same for each)","Passwort für entfernten Zugriff: (kann dasselbe sein für alle)" }, | 89 | { "Password for remote access: (could be the same for each)","Passwort für entfernten Zugriff: (kann dasselbe sein für alle)" }, |
90 | { "Remote IP address: (could be the same for each)","Entfernte IP Adresse: (kann dasselbe sein für alle)" }, | 90 | { "Remote IP address: (could be the same for each)","Entfernte IP Adresse: (kann dasselbe sein für alle)" }, |
91 | { "Remote port number: (should be different for each)","Entfernte Port Nummer: (Sollte für alle unterschiedlich sein)" }, | 91 | { "Remote port number: (should be different for each)","Entfernte Port Nummer: (Sollte für alle unterschiedlich sein)" }, |
92 | { "command for downloading remote file to local device","Kommando zum Download der entfernten Datei zum lokalen Gerät" }, | 92 | { "command for downloading remote file to local device","Kommando zum Download der entfernten Datei zum lokalen Gerät" }, |
93 | { "command for uploading local temp file to remote device","Kommando zum Upload der lokalen temp. Datei zum entfernten Gerät" }, | 93 | { "command for uploading local temp file to remote device","Kommando zum Upload der lokalen temp. Datei zum entfernten Gerät" }, |
94 | { "No Filter","Kein Filter" }, | 94 | { "No Filter","Kein Filter" }, |
95 | { "KO/Pi config error","KO/Pi Konfig. Fehler" }, | 95 | { "KO/Pi config error","KO/Pi Konfig. Fehler" }, |
96 | { "Local device name undefined!\nPlease define device name!","Name dieses Gerätes undefiniert!\nBitte Namen angeben!" }, | 96 | { "Local device name undefined!\nPlease define device name!","Name dieses Gerätes undefiniert!\nBitte Namen angeben!" }, |
97 | { "Multiple profiles with same name!\nPlease use unique profile names!","Mehrere Profile mit demselben Namen!\nBitte verschiedene Namen benutzen!" }, | 97 | { "Multiple profiles with same name!\nPlease use unique profile names!","Mehrere Profile mit demselben Namen!\nBitte verschiedene Namen benutzen!" }, |
98 | { "Configure","Konfiguriere" }, | 98 | { "Configure","Konfiguriere" }, |
99 | { "Apply","Anwenden" }, | 99 | { "Apply","Anwenden" }, |
100 | { "None","Kein" }, | 100 | { "None","Kein" }, |
101 | { "Global","Allgemein" }, | 101 | { "Global","Allgemein" }, |
102 | { "Email","E-Mail" }, | 102 | { "Email","E-Mail" }, |
103 | { "Phone","Telefon" }, | 103 | { "Phone","Telefon" }, |
104 | { "SMS","SMS" }, | 104 | { "SMS","SMS" }, |
105 | { "Fax","Fax" }, | 105 | { "Fax","Fax" }, |
106 | { "Pager","Pager" }, | 106 | { "Pager","Pager" }, |
107 | { "SIP","SIP" }, | 107 | { "SIP","SIP" }, |
108 | { "Language:(needs restart)","Sprache:(Neustart)" }, | 108 | { "Language:(needs restart)","Sprache:(Neustart)" }, |
109 | { "English","English" }, | 109 | { "English","English" }, |
110 | { "German","Deutsch" }, | 110 | { "German","Deutsch" }, |
111 | { "French","Französisch" }, | 111 | { "French","Französisch" }, |
112 | { "Italian","Italienisch" }, | 112 | { "Italian","Italienisch" }, |
113 | { "User defined (usertranslation.txt)","Benutzerdef. (usertranslation.txt)" }, | 113 | { "User defined (usertranslation.txt)","Benutzerdef. (usertranslation.txt)" }, |
114 | { "Language","Sprache" }, | 114 | { "Language","Sprache" }, |
115 | { "Time Format(nr):","Zeit Format(nr):" }, | 115 | { "Time Format(nr):","Zeit Format(nr):" }, |
116 | { "24:00","24:00" }, | 116 | { "24:00","24:00" }, |
117 | { "12:00am","12:00am" }, | 117 | { "12:00am","12:00am" }, |
118 | { "Week starts on Sunday","Woche beginnt Sonntags" }, | 118 | { "Week starts on Sunday","Woche beginnt Sonntags" }, |
119 | { "Time Format","Zeit Format" }, | 119 | { "Time Format","Zeit Format" }, |
120 | { "Date Format:","Datums Format:" }, | 120 | { "Date Format:","Datums Format:" }, |
121 | { "24.03.2004 (%d.%m.%Y|%A %d %B %Y)","24.03.2004 (%d.%m.%Y|%A %d %B %Y)" }, | 121 | { "24.03.2004 (%d.%m.%Y|%A %d %B %Y)","24.03.2004 (%d.%m.%Y|%A %d %B %Y)" }, |
122 | { "03.24.2004 (%m.%d.%Y|%A %B %d %Y)","03.24.2004 (%m.%d.%Y|%A %B %d %Y)" }, | 122 | { "03.24.2004 (%m.%d.%Y|%A %B %d %Y)","03.24.2004 (%m.%d.%Y|%A %B %d %Y)" }, |
123 | { "2004-03-24 (%Y-%m-%d|%A %Y %B %d)","2004-03-24 (%Y-%m-%d|%A %Y %B %d)" }, | 123 | { "2004-03-24 (%Y-%m-%d|%A %Y %B %d)","2004-03-24 (%Y-%m-%d|%A %Y %B %d)" }, |
124 | { "User defined","Benutzerdefiniert" }, | 124 | { "User defined","Benutzerdefiniert" }, |
125 | { "User long date:","Format langes Datum:" }, | 125 | { "User long date:","Format langes Datum:" }, |
126 | { "User short date:","Format kurzes Datum:" }, | 126 | { "User short date:","Format kurzes Datum:" }, |
127 | { "Monday 19 April 2004: %A %d %B %Y","Monday 19 April 2004: %A %d %B %Y" }, | 127 | { "Monday 19 April 2004: %A %d %B %Y","Monday 19 April 2004: %A %d %B %Y" }, |
128 | { "Mon 19.04.04: %a %d.%m.%y","Mon 19.04.04: %a %d.%m.%y" }, | 128 | { "Mon 19.04.04: %a %d.%m.%y","Mon 19.04.04: %a %d.%m.%y" }, |
129 | { "Mon, 19.Apr.04: %a, %d.%b.%y","Mon, 19.Apr.04: %a, %d.%b.%y" }, | 129 | { "Mon, 19.Apr.04: %a, %d.%b.%y","Mon, 19.Apr.04: %a, %d.%b.%y" }, |
130 | { "Date Format","Datums Format" }, | 130 | { "Date Format","Datums Format" }, |
131 | { "Timezone:","Zeitzone:" }, | 131 | { "Timezone:","Zeitzone:" }, |
132 | { "Add 30 min to selected Timezone","Addiere 30 min zur Zeitzone" }, | 132 | { "Add 30 min to selected Timezone","Addiere 30 min zur Zeitzone" }, |
133 | { "Timezone has daylight saving","Zeitzone hat Sommerzeit" }, | 133 | { "Timezone has daylight saving","Zeitzone hat Sommerzeit" }, |
134 | { "Actual start and end is the\nsunday before this date.","Tatsächlicher Beginn/Ende ist der\nSonntag vor diesem Datum!" }, | 134 | { "Actual start and end is the\nsunday before this date.","Tatsächlicher Beginn/Ende ist der\nSonntag vor diesem Datum!" }, |
135 | { "The year in the date is ignored.","Das Jahr vom Datum wird ignoriert." }, | 135 | { "The year in the date is ignored.","Das Jahr vom Datum wird ignoriert." }, |
136 | { "Daylight start:","Sommerzeit Beginn:" }, | 136 | { "Daylight start:","Sommerzeit Beginn:" }, |
137 | { "Mon","Mo" }, | 137 | { "Mon","Mo" }, |
138 | { "Tue","Di" }, | 138 | { "Tue","Di" }, |
139 | { "Wed","Mi" }, | 139 | { "Wed","Mi" }, |
140 | { "Thu","Do" }, | 140 | { "Thu","Do" }, |
141 | { "Fri","Fr" }, | 141 | { "Fri","Fr" }, |
142 | { "Sat","Sa" }, | 142 | { "Sat","Sa" }, |
143 | { "Sun","So" }, | 143 | { "Sun","So" }, |
144 | { "January","Januar" }, | 144 | { "January","Januar" }, |
145 | { "February","Februar" }, | 145 | { "February","Februar" }, |
146 | { "March","März" }, | 146 | { "March","März" }, |
147 | { "April","April" }, | 147 | { "April","April" }, |
148 | { "May","Mai" }, | 148 | { "May","Mai" }, |
149 | { "June","Juni" }, | 149 | { "June","Juni" }, |
150 | { "July","July" }, | 150 | { "July","July" }, |
151 | { "August","August" }, | 151 | { "August","August" }, |
152 | { "September","September" }, | 152 | { "September","September" }, |
153 | { "October","October" }, | 153 | { "October","October" }, |
154 | { "November","November" }, | 154 | { "November","November" }, |
155 | { "December","Dezember" }, | 155 | { "December","Dezember" }, |
156 | { "tomorrow","Morgen" }, | 156 | { "tomorrow","Morgen" }, |
157 | { "today","Heute" }, | 157 | { "today","Heute" }, |
158 | { "yesterday","Gestern" }, | 158 | { "yesterday","Gestern" }, |
159 | { "Monday","Montag" }, | 159 | { "Monday","Montag" }, |
160 | { "Tuesday","Dienstag" }, | 160 | { "Tuesday","Dienstag" }, |
161 | { "Wednesday","Mittwoch" }, | 161 | { "Wednesday","Mittwoch" }, |
162 | { "Thursday","Donnerstag" }, | 162 | { "Thursday","Donnerstag" }, |
163 | { "Friday","Freitag" }, | 163 | { "Friday","Freitag" }, |
164 | { "Saturday","Samstag" }, | 164 | { "Saturday","Samstag" }, |
165 | { "Sunday","Sonntag" }, | 165 | { "Sunday","Sonntag" }, |
166 | { "Daylight end:","Sommerzeit Ende:" }, | 166 | { "Daylight end:","Sommerzeit Ende:" }, |
167 | { "Time Zone","Zeit Zone" }, | 167 | { "Time Zone","Zeit Zone" }, |
168 | { "Used Mail Client","Benutzter Mail Client" }, | 168 | { "Used Mail Client","Benutzter Mail Client" }, |
169 | { "Channel:","Channel:" }, | 169 | { "Channel:","Channel:" }, |
170 | { "Message:","Message:" }, | 170 | { "Message:","Message:" }, |
171 | { "Parameters:","Parameter:" }, | 171 | { "Parameters:","Parameter:" }, |
172 | { "HINT: Delimiter=; Name=%1,Email=%2","Hinweis: Begrenzer=; Name=%1,Email=%2" }, | 172 | { "HINT: Delimiter=; Name=%1,Email=%2","Hinweis: Begrenzer=; Name=%1,Email=%2" }, |
173 | { "extra Message:","extra Message:" }, | 173 | { "extra Message:","extra Message:" }, |
174 | { "extra Parameters:","extra Parameter:" }, | 174 | { "extra Parameters:","extra Parameter:" }, |
175 | { "HINT: Emails=%1,Attachments=%2","Hinweis: Emails=%1,Attachments=%2" }, | 175 | { "HINT: Emails=%1,Attachments=%2","Hinweis: Emails=%1,Attachments=%2" }, |
176 | { "External Apps.","Externe Appl." }, | 176 | { "External Apps.","Externe Appl." }, |
177 | { "Your current storage dir is:\n%1\nYour mail is stored in:\n(storagedir)/apps/kopiemail/localmail","Aktuelles Speicherverzeichnis ist:\n%1\nIhre Mail wird gespeichert in:\n(speicherverz.)/apps/kopiemail/localmail" }, | 177 | { "Your current storage dir is:\n%1\nYour mail is stored in:\n(storagedir)/apps/kopiemail/localmail","Aktuelles Speicherverzeichnis ist:\n%1\nIhre Mail wird gespeichert in:\n(speicherverz.)/apps/kopiemail/localmail" }, |
178 | { "<b>New data storage dir:</b>","<b>Neues Datenspeicherverzeichnis:</b>" }, | 178 | { "<b>New data storage dir:</b>","<b>Neues Datenspeicherverzeichnis:</b>" }, |
179 | { "New dirs are created automatically","Neue Verzeichnisse werden aut. erstellt" }, | 179 | { "New dirs are created automatically","Neue Verzeichnisse werden aut. erstellt" }, |
180 | { "Save settings","Speichere Einstellungen" }, | 180 | { "Save settings","Speichere Einstellungen" }, |
181 | { "Save standard","Speichere Standard" }, | 181 | { "Save standard","Speichere Standard" }, |
182 | { "<b>New settings are used\nafter a restart</b>","<b>Neue Einstellungen werden nach\neinem Neustart genutzt</b>" }, | 182 | { "<b>New settings are used\nafter a restart</b>","<b>Neue Einstellungen werden nach\neinem Neustart genutzt</b>" }, |
183 | { "Settings are stored in\n%1","Einstellungen werden gespeichert in:\n%1" }, | 183 | { "Settings are stored in\n%1","Einstellungen werden gespeichert in:\n%1" }, |
184 | { "Data storage path","Daten Speicherpfad" }, | 184 | { "Data storage path","Daten Speicherpfad" }, |
185 | { "Used %1 Client","Benutzer %1 Client" }, | 185 | { "Used %1 Client","Benutzer %1 Client" }, |
186 | { "No email client installed","Keine Email Client installiert" }, | 186 | { "No email client installed","Keine Email Client installiert" }, |
187 | { "Userdefined email client","Benutzerdef. Email Client" }, | 187 | { "Userdefined email client","Benutzerdef. Email Client" }, |
188 | { "OM/Pi email client","OM/Pi Email Client" }, | 188 | { "OM/Pi email client","OM/Pi Email Client" }, |
189 | { "URL:","URL:" }, | 189 | { "URL:","URL:" }, |
190 | { "No","Nein" }, | 190 | { "No","Nein" }, |
191 | { "Yes","Ja" }, | 191 | { "Yes","Ja" }, |
192 | { "Untitled","Unbenannt" }, | 192 | { "Untitled","Unbenannt" }, |
193 | { "&New","&Neu" }, | 193 | { "&New","&Neu" }, |
194 | { "&Open","&Öffne" }, | 194 | { "&Open","&Öffne" }, |
195 | { "&Close","Schließen" }, | 195 | { "&Close","Schließen" }, |
196 | { "Save &as...","Speichere &als..." }, | 196 | { "Save &as...","Speichere &als..." }, |
197 | { "&Text-file...","&Text-Datei..." }, | 197 | { "&Text-file...","&Text-Datei..." }, |
198 | { "&Gpasman / Kpasman ...","&Gpasman / Kpasman ..." }, | 198 | { "&Gpasman / Kpasman ...","&Gpasman / Kpasman ..." }, |
199 | { "&CSV (Comma Separated Value) ...","&CSV (Komma getrennte Werte) ..." }, | 199 | { "&CSV (Comma Separated Value) ...","&CSV (Komma getrennte Werte) ..." }, |
200 | { "E&xport","E&xport" }, | 200 | { "E&xport","E&xport" }, |
201 | { "I&mport","I&mport" }, | 201 | { "I&mport","I&mport" }, |
202 | { "&Quit","Beenden" }, | 202 | { "&Quit","Beenden" }, |
203 | { "&Add password","&Passwort hinzufügen" }, | 203 | { "&Add password","&Passwort hinzufügen" }, |
204 | { "&Delete","Lösche" }, | 204 | { "&Delete","Lösche" }, |
205 | { "Change &Master Password","Ändere &Master Passwort" }, | 205 | { "Change &Master Password","Ändere &Master Passwort" }, |
206 | { "&Manage","Verwalte" }, | 206 | { "&Manage","Verwalte" }, |
207 | { "&Find","&Finde" }, | 207 | { "&Find","&Finde" }, |
208 | { "&Lock all entries","Sperre alle Einträge" }, | 208 | { "&Lock all entries","Sperre alle Einträge" }, |
209 | { "&Deep-lock all entries","Sperre total alle Einträge" }, | 209 | { "&Deep-lock all entries","Sperre total alle Einträge" }, |
210 | { "&Unlock all entries","Entsperre alle Einträge" }, | 210 | { "&Unlock all entries","Entsperre alle Einträge" }, |
211 | { "&Configure...","Konfiguriere..." }, | 211 | { "&Configure...","Konfiguriere..." }, |
212 | { "&Options","Konfig" }, | 212 | { "&Options","Konfig" }, |
213 | { "C&ategories...","K&ategorien..." }, | 213 | { "C&ategories...","K&ategorien..." }, |
214 | { "&Sync","&Sync" }, | 214 | { "&Sync","&Sync" }, |
215 | { "&License","&Lizenz" }, | 215 | { "&License","&Lizenz" }, |
216 | { "&Faq","&Faq" }, | 216 | { "&Faq","&Faq" }, |
217 | { "&About PwManager","Über PwManager" }, | 217 | { "&About PwManager","Über PwManager" }, |
218 | { "&Sync HowTo","&Sync HowTo" }, | 218 | { "&Sync HowTo","&Sync HowTo" }, |
219 | { "&What's New","Was ist neu?" }, | 219 | { "&What's New","Was ist neu?" }, |
220 | { "New","Neu" }, | 220 | { "New","Neu" }, |
221 | { "Open","Öffnen" }, | 221 | { "Open","Öffnen" }, |
222 | { "Save","Speichern" }, | 222 | { "Save","Speichern" }, |
223 | { "Save as","Speichern als" }, | 223 | { "Save as","Speichern als" }, |
224 | { "Print...","Drucke..." }, | 224 | { "Print...","Drucke..." }, |
225 | { "Add password","Passwort hinzufügen" }, | 225 | { "Add password","Passwort hinzufügen" }, |
226 | { "Edit password","Passwort ändern" }, | 226 | { "Edit password","Passwort ändern" }, |
227 | { "Delete password","Passwort löschen" }, | 227 | { "Delete password","Passwort löschen" }, |
228 | { "Find entry","Finde Eintrag" }, | 228 | { "Find entry","Finde Eintrag" }, |
229 | { "Lock all entries","Sperre alle Einträge" }, | 229 | { "Lock all entries","Sperre alle Einträge" }, |
230 | { "Deep-Lock all entries","Sperre total alle Einträge" }, | 230 | { "Deep-Lock all entries","Sperre total alle Einträge" }, |
231 | { "Unlock all entries","Entsperre alle Einträge" }, | 231 | { "Unlock all entries","Entsperre alle Einträge" }, |
232 | { "Categories:","Kategorien:" }, | 232 | { "Categories:","Kategorien:" }, |
233 | { "&Rename","&Umbenennen" }, | 233 | { "&Rename","&Umbenennen" }, |
234 | { "Username","Benutzername" }, | 234 | { "Username","Benutzername" }, |
235 | { "Password","Passwort" }, | 235 | { "Password","Passwort" }, |
236 | { "Launcher","Launcher" }, | 236 | { "Launcher","Launcher" }, |
237 | { "copy password to clipboard","Kopiere Passwort ins Clipboard" }, | 237 | { "copy password to clipboard","Kopiere Passwort ins Clipboard" }, |
238 | { "copy username to clipboard","Kopiere Benutzername ins Clipboard" }, | 238 | { "copy username to clipboard","Kopiere Benutzername ins Clipboard" }, |
239 | { "copy description to clipboard","Kopiere Beschreibung ins Clipboard" }, | 239 | { "copy description to clipboard","Kopiere Beschreibung ins Clipboard" }, |
240 | { "copy url to clipboard","Kopiere URL ins Clipboard" }, | 240 | { "copy url to clipboard","Kopiere URL ins Clipboard" }, |
241 | { "copy launcher to clipboard","Kopiere Launcher ins Clipboard" }, | 241 | { "copy launcher to clipboard","Kopiere Launcher ins Clipboard" }, |
242 | { "copy comment to clipboard","Kopiere Kommentare ins Clipboard" }, | 242 | { "copy comment to clipboard","Kopiere Kommentare ins Clipboard" }, |
243 | { "Execute "Launcher"",""Launcher" ausführen" }, | 243 | { "Execute "Launcher"",""Launcher" ausführen" }, |
244 | { "Go to "URL"","Gehe zu "URL"" }, | 244 | { "Go to "URL"","Gehe zu "URL"" }, |
245 | { "Ready.","Fertig." }, | 245 | { "Ready.","Fertig." }, |
246 | { "password filename(*.pwm)","passwort dateiname(*.pwm)" }, | 246 | { "password filename(*.pwm)","passwort dateiname(*.pwm)" }, |
247 | { "File error","Datei Fehler" }, | 247 | { "File error","Datei Fehler" }, |
248 | { "Could not read file!","Kann Datei nicht lesen!" }, | 248 | { "Could not read file!","Kann Datei nicht lesen!" }, |
249 | { "Master-password","Master-Passwort" }, | 249 | { "Master-password","Master-Passwort" }, |
250 | { "Please enter the master-password:","Bitter Master-Passwort eingeben:" }, | 250 | { "Please enter the master-password:","Bitter Master-Passwort eingeben:" }, |
251 | { "Wrong master-password!\nPlease try again.","Falsches Master-Passwort!\nBitte erneut versuchen." }, | 251 | { "Wrong master-password!\nPlease try again.","Falsches Master-Passwort!\nBitte erneut versuchen." }, |
252 | { "password error","Passwort Fehler" }, | 252 | { "password error","Passwort Fehler" }, |
253 | { "Successfully opened file.","Datei erfolgreich geöffnet." }, | 253 | { "Successfully opened file.","Datei erfolgreich geöffnet." }, |
254 | { "DEEP-LOCKED","TOTAL-GESPERRT" }, | 254 | { "DEEP-LOCKED","TOTAL-GESPERRT" }, |
255 | { "This file is DEEP-LOCKED!\nThat means all data has been encrypted\nand written out to the file. If you want\nto see the entries, please UNLOCK the file.\nWhile unlocking, you will be prompted for the\nmaster-password or the key-card.","Diese Datei ist TOTAL-GESPERRT!\nDas bedeutet, dass alle Daten verschlüsselt\nsind und in die Datei geschrieben wurden.\nWenn Sie die Einträge sehen möchten\nENTSPERREN Sie bitte die Datei.\nZum Entsperren werden Sie nach\ndem Master-Passwort gefragt." }, | 255 | { "This file is DEEP-LOCKED!\nThat means all data has been encrypted\nand written out to the file. If you want\nto see the entries, please UNLOCK the file.\nWhile unlocking, you will be prompted for the\nmaster-password or the key-card.","Diese Datei ist TOTAL-GESPERRT!\nDas bedeutet, dass alle Daten verschlüsselt\nsind und in die Datei geschrieben wurden.\nWenn Sie die Einträge sehen möchten\nENTSPERREN Sie bitte die Datei.\nZum Entsperren werden Sie nach\ndem Master-Passwort gefragt." }, |
256 | { "<LOCKED>","<GESPERRT>" }, | 256 | { "<LOCKED>","<GESPERRT>" }, |
257 | { "To unlock click the icon on the left.","Zum Entsperren auf linkes Icon klicken." }, | 257 | { "To unlock click the icon on the left.","Zum Entsperren auf linkes Icon klicken." }, |
258 | { "PwManager","PwManager" }, | 258 | { "PwManager","PwManager" }, |
259 | { "Window-style:","Window-Stil:" }, | 259 | { "Window-style:","Window-Stil:" }, |
260 | { "Category on top","Kategorien oben" }, | 260 | { "Category on top","Kategorien oben" }, |
261 | { "Category-list left/top","Kategorien links oben" }, | 261 | { "Category-list left/top","Kategorien links oben" }, |
262 | { "Font for Password entries:","Schrift für Passwort Einträge:" }, | 262 | { "Font for Password entries:","Schrift für Passwort Einträge:" }, |
263 | { "Font for Password summary:","Schrift für Passwort Übersicht:" }, | 263 | { "Font for Password summary:","Schrift für Passwort Übersicht:" }, |
264 | { "Font:","Schriftart:" }, | 264 | { "Font:","Schriftart:" }, |
265 | { "Summary","Übersicht" }, | 265 | { "Summary","Übersicht" }, |
266 | { "Compression:","Kompression:" }, | 266 | { "Compression:","Kompression:" }, |
267 | { "gzip","gzip" }, | 267 | { "gzip","gzip" }, |
268 | { "Encryption:","Verschlüsselung:" }, | 268 | { "Encryption:","Verschlüsselung:" }, |
269 | { "Blowfish (128 bit)","Blowfish (128 bit)" }, | 269 | { "Blowfish (128 bit)","Blowfish (128 bit)" }, |
270 | { "AES-128, Rijndael (128 bit)","AES-128, Rijndael (128 bit)" }, | 270 | { "AES-128, Rijndael (128 bit)","AES-128, Rijndael (128 bit)" }, |
271 | { "AES-192, Rijndael (192 bit)","AES-192, Rijndael (192 bit)" }, | 271 | { "AES-192, Rijndael (192 bit)","AES-192, Rijndael (192 bit)" }, |
272 | { "AES-256, Rijndael (256 bit)","AES-256, Rijndael (256 bit)" }, | 272 | { "AES-256, Rijndael (256 bit)","AES-256, Rijndael (256 bit)" }, |
273 | { "Triple-DES (168 bit)","Triple-DES (168 bit)" }, | 273 | { "Triple-DES (168 bit)","Triple-DES (168 bit)" }, |
274 | { "Twofish (256 bit)","Twofish (256 bit)" }, | 274 | { "Twofish (256 bit)","Twofish (256 bit)" }, |
275 | { "Twofish-128 (128 bit)","Twofish-128 (128 bit)" }, | 275 | { "Twofish-128 (128 bit)","Twofish-128 (128 bit)" }, |
276 | { "Hashing:","Hashing:" }, | 276 | { "Hashing:","Hashing:" }, |
277 | { "SHA-160, SHA1 (160 bit)","SHA-160, SHA1 (160 bit)" }, | 277 | { "SHA-160, SHA1 (160 bit)","SHA-160, SHA1 (160 bit)" }, |
278 | { "SHA-256 (256 bit)","SHA-256 (256 bit)" }, | 278 | { "SHA-256 (256 bit)","SHA-256 (256 bit)" }, |
279 | { "SHA-384 (384 bit)","SHA-384 (384 bit)" }, | 279 | { "SHA-384 (384 bit)","SHA-384 (384 bit)" }, |
280 | { "SHA-512 (512 bit)","SHA-512 (512 bit)" }, | 280 | { "SHA-512 (512 bit)","SHA-512 (512 bit)" }, |
281 | { "MD5 (128 bit)","MD5 (128 bit)" }, | 281 | { "MD5 (128 bit)","MD5 (128 bit)" }, |
282 | { "RIPE-MD-160 (160 bit)","RIPE-MD-160 (160 bit)" }, | 282 | { "RIPE-MD-160 (160 bit)","RIPE-MD-160 (160 bit)" }, |
283 | { "Tiger (192 bit)","Tiger (192 bit)" }, | 283 | { "Tiger (192 bit)","Tiger (192 bit)" }, |
284 | { "Permissions:","Zugriffsrechte:" }, | 284 | { "Permissions:","Zugriffsrechte:" }, |
285 | { "Make backup before saving","Mache Backup vor dem Speichern" }, | 285 | { "Make backup before saving","Mache Backup vor dem Speichern" }, |
286 | { "Password timeout\n(timeout to hold password in\nmemory,so you don't have to\nre-enter it,if you\nalready have entered it)\n[set to 0 to disable]:","Passwort Timeout\n(Timeout um das Passwort\nim Speicher zu halten,\nso dass es nicht noch mal\neingegeben werden muß.)\n[Setze auf 0 zum deaktivieren]:" }, | 286 | { "Password timeout\n(timeout to hold password in\nmemory,so you don't have to\nre-enter it,if you\nalready have entered it)\n[set to 0 to disable]:","Passwort Timeout\n(Timeout um das Passwort\nim Speicher zu halten,\nso dass es nicht noch mal\neingegeben werden muß.)\n[Setze auf 0 zum deaktivieren]:" }, |
287 | { "Auto-lock timeout\n(auto lock document after this\namount of seconds)\n[set to 0 to disable]:","(Total-)Sperr-Timeout\n(Sperre Dokument total nach\ndieser Anzahl Sekunden)\n[Setze auf 0 zum deaktivieren]:" }, | 287 | { "Auto-lock timeout\n(auto lock document after this\namount of seconds)\n[set to 0 to disable]:","(Total-)Sperr-Timeout\n(Sperre Dokument total nach\ndieser Anzahl Sekunden)\n[Setze auf 0 zum deaktivieren]:" }, |
288 | { "deep-lock on autolock","Sperre total beim Sperr-Timeout" }, | 288 | { "deep-lock on autolock","Sperre total beim Sperr-Timeout" }, |
289 | { "open deeplocked","Öffne total gesperrt" }, | 289 | { "open deeplocked","Öffne total gesperrt" }, |
290 | { "Favourite browser:","Bevorzugter Browser:" }, | 290 | { "Favourite browser:","Bevorzugter Browser:" }, |
291 | { "Favourite x-terminal:","Bevorzugtes x-terminal:" }, | 291 | { "Favourite x-terminal:","Bevorzugtes x-terminal:" }, |
292 | { "Open document with passwords unlocked","Öffne Dokument mit Passwort ungesperrt" }, | 292 | { "Open document with passwords unlocked","Öffne Dokument mit Passwort ungesperrt" }, |
293 | { "Look && feel","Aussehen" }, | 293 | { "Look && feel","Aussehen" }, |
294 | { "File","Datei" }, | 294 | { "File","Datei" }, |
295 | { "Timeout","Timeout" }, | 295 | { "Timeout","Timeout" }, |
296 | { "Autostart","Autostart" }, | 296 | { "Autostart","Autostart" }, |
297 | { "External apps","Externe Applik." }, | 297 | { "External apps","Externe Applik." }, |
298 | { "Miscellaneous","Verschiedenes" }, | 298 | { "Miscellaneous","Verschiedenes" }, |
299 | { "+01:00 Europe/Oslo(CET)","+01:00 Europe/Oslo(CET)" }, | 299 | { "+01:00 Europe/Oslo(CET)","+01:00 Europe/Oslo(CET)" }, |
300 | { "edit category descriptions","Ändere Label für Kategorie" }, | 300 | { "edit category descriptions","Ändere Label für Kategorie" }, |
301 | { "Close","Schließen" }, | 301 | { "Close","Schließen" }, |
302 | { "Category:","Category:" }, | 302 | { "Category:","Category:" }, |
303 | { "Text1 (Description):","Text1 (Beschreibung):" }, | 303 | { "Text1 (Description):","Text1 (Beschreibung):" }, |
304 | { "Text2 (Username):","Text2 (Benutzername):" }, | 304 | { "Text2 (Username):","Text2 (Benutzername):" }, |
305 | { "Text3 (Password):","Text3 (Passwort):" }, | 305 | { "Text3 (Password):","Text3 (Passwort):" }, |
306 | { "edit/add a password entry","Ändere/hinzufüge Passwort Eintrag" }, | 306 | { "edit/add a password entry","Ändere/hinzufüge Passwort Eintrag" }, |
307 | { "Description:","Beschreibung:" }, | 307 | { "Description:","Beschreibung:" }, |
308 | { "Username:","Benutzername:" }, | 308 | { "Username:","Benutzername:" }, |
309 | { "Password:","Passwort:" }, | 309 | { "Password:","Passwort:" }, |
310 | { "&Reveal","&Offen zeigen" }, | 310 | { "&Reveal","&Offen zeigen" }, |
311 | { "&Generate","&Generiere" }, | 311 | { "&Generate","&Generiere" }, |
312 | { "&Password","&Passwort" }, | 312 | { "&Password","&Passwort" }, |
313 | { "&Comments","Kommentar" }, | 313 | { "&Comments","Kommentar" }, |
314 | { "Launcher:","Launcher:" }, | 314 | { "Launcher:","Launcher:" }, |
315 | { "$d = Description","$d = Beschreibung" }, | 315 | { "$d = Description","$d = Beschreibung" }, |
316 | { "$n = Username","$n = Benutzername" }, | 316 | { "$n = Username","$n = Benutzername" }, |
317 | { "$c = Comment","$c = Kommentar" }, | 317 | { "$c = Comment","$c = Kommentar" }, |
318 | { "$u = URL","$u = URL" }, | 318 | { "$u = URL","$u = URL" }, |
319 | { "$p = Password","$p = Passwort" }, | 319 | { "$p = Password","$p = Passwort" }, |
320 | { "&Launcher","&Launcher" }, | 320 | { "&Launcher","&Launcher" }, |
321 | { "Password generator","Passwort Generator" }, | 321 | { "Password generator","Passwort Generator" }, |
322 | { "Character set:","Buchstaben Set:" }, | 322 | { "Character set:","Buchstaben Set:" }, |
323 | { "Lowercase (abc)","Klein (abc)" }, | 323 | { "Lowercase (abc)","Klein (abc)" }, |
324 | { "Uppercase (ABC)","Groß (ABC)" }, | 324 | { "Uppercase (ABC)","Groß (ABC)" }, |
325 | { "Numbers (123)","Nummmern (123)" }, | 325 | { "Numbers (123)","Nummmern (123)" }, |
326 | { "Special characters:","Spezielle Buchstaben:" }, | 326 | { "Special characters:","Spezielle Buchstaben:" }, |
327 | { "Spaces (blank characters)","Leerzeichen" }, | 327 | { "Spaces (blank characters)","Leerzeichen" }, |
328 | { "User defined:","Benutzer definiert:" }, | 328 | { "User defined:","Benutzer definiert:" }, |
329 | { "Password Length:","Passwort Länge:" }, | 329 | { "Password Length:","Passwort Länge:" }, |
330 | { "Enable Filtering to get better passwords","Enable Filtering to get better passwords" }, | 330 | { "Enable Filtering to get better passwords","Enable Filtering to get better passwords" }, |
331 | { "no password","Kein Passwort" }, | 331 | { "no password","Kein Passwort" }, |
332 | { "Sorry, you haven't set a password.","Sorry, Sie haben kein Passwort angegeben." }, | 332 | { "Sorry, you haven't set a password.","Sorry, Sie haben kein Passwort angegeben." }, |
333 | { "not saved, yet","not saved, yet" }, | 333 | { "not saved, yet","not saved, yet" }, |
334 | { "Can't deep-lock, because the document\nhasn't been saved, yet. Please save\nto a file and try again.","Kann nicht tiefsperren, weil das\nDokument noch nicht gespeichert wurde.\nBitte speichern und noch einmal versuchen." }, | 334 | { "Can't deep-lock, because the document\nhasn't been saved, yet. Please save\nto a file and try again.","Kann nicht tiefsperren, weil das\nDokument noch nicht gespeichert wurde.\nBitte speichern und noch einmal versuchen." }, |
335 | { "Find","Finde" }, | 335 | { "Find","Finde" }, |
336 | { "&Exact match","Genaue Übereinstimmung" }, | 336 | { "&Exact match","Genaue Übereinstimmung" }, |
337 | { "&Case sensitive","Großschrift abhängig" }, | 337 | { "&Case sensitive","Großschrift abhängig" }, |
338 | { "Search in Column","Suche in Spalten" }, | 338 | { "Search in Column","Suche in Spalten" }, |
339 | { "&Description","Beschreibung" }, | 339 | { "&Description","Beschreibung" }, |
340 | { "C&omment","Kommentar" }, | 340 | { "C&omment","Kommentar" }, |
341 | { "&Username","Benutzername" }, | 341 | { "&Username","Benutzername" }, |
342 | { "U&RL","URL" }, | 342 | { "U&RL","URL" }, |
343 | { "delete?","Löschen?" }, | 343 | { "delete?","Löschen?" }, |
344 | { "Do you really want to delete\nthe selected entry","Wollen Sie wirklich\nden Eintrag löschen:" }, | 344 | { "Do you really want to delete\nthe selected entry","Wollen Sie wirklich\nden Eintrag löschen:" }, |
345 | { "Save?","Speichern?" }, | 345 | { "Save?","Speichern?" }, |
346 | { ""\nhas been modified.\nDo you want to save it?",""\nwurde geändert.\nMöchten Sie speichern?" }, | 346 | { ""\nhas been modified.\nDo you want to save it?",""\nwurde geändert.\nMöchten Sie speichern?" }, |
347 | { "The list\n "","Die Liste\n "" }, | 347 | { "The list\n "","Die Liste\n "" }, |
348 | { "nothing to do","Nichts zu tun" }, | 348 | { "nothing to do","Nichts zu tun" }, |
349 | { "Sorry, there's nothing to save.\nPlease first add some passwords.","Sorry, es gibt nichts zu speichern.\nBitte erst Passwörter hinzufügen." }, | 349 | { "Sorry, there's nothing to save.\nPlease first add some passwords.","Sorry, es gibt nichts zu speichern.\nBitte erst Passwörter hinzufügen." }, |
350 | { "Add new password","Passwort hinzufügen" }, | 350 | { "Add new password","Passwort hinzufügen" }, |
351 | { "Successfully saved data.","Datei gespeichert." }, | 351 | { "Successfully saved data.","Datei gespeichert." }, |
352 | { "Category:","Kategorie:" }, | 352 | { "Category:","Kategorie:" }, |
353 | { "LOCKED","GESPERRT" }, | ||
354 | { "","" }, | ||
355 | { "","" }, | ||
356 | { "","" }, | ||
353 | { "","" }, | 357 | { "","" }, |
354 | { "","" }, | 358 | { "","" }, |
355 | { "","" }, | 359 | { "","" }, |
356 | 360 | ||
diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp index 6fbe110..61f2616 100644 --- a/pwmanager/pwmanager/pwmdoc.cpp +++ b/pwmanager/pwmanager/pwmdoc.cpp | |||
@@ -1,2829 +1,2829 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * copyright (C) 2003, 2004 by Michael Buesch * | 3 | * copyright (C) 2003, 2004 by Michael Buesch * |
4 | * email: mbuesch@freenet.de * | 4 | * email: mbuesch@freenet.de * |
5 | * * | 5 | * * |
6 | * This program is free software; you can redistribute it and/or modify * | 6 | * This program is free software; you can redistribute it and/or modify * |
7 | * it under the terms of the GNU General Public License version 2 * | 7 | * it under the terms of the GNU General Public License version 2 * |
8 | * as published by the Free Software Foundation. * | 8 | * as published by the Free Software Foundation. * |
9 | * * | 9 | * * |
10 | ***************************************************************************/ | 10 | ***************************************************************************/ |
11 | 11 | ||
12 | /*************************************************************************** | 12 | /*************************************************************************** |
13 | * copyright (C) 2004 by Ulf Schenk | 13 | * copyright (C) 2004 by Ulf Schenk |
14 | * This file is originaly based on version 1.1 of pwmanager | 14 | * This file is originaly based on version 1.1 of pwmanager |
15 | * and was modified to run on embedded devices that run microkde | 15 | * and was modified to run on embedded devices that run microkde |
16 | * | 16 | * |
17 | * $Id$ | 17 | * $Id$ |
18 | **************************************************************************/ | 18 | **************************************************************************/ |
19 | 19 | ||
20 | #include "pwmdoc.h" | 20 | #include "pwmdoc.h" |
21 | #include "pwmview.h" | 21 | #include "pwmview.h" |
22 | #include "blowfish.h" | 22 | #include "blowfish.h" |
23 | #include "sha1.h" | 23 | #include "sha1.h" |
24 | #include "globalstuff.h" | 24 | #include "globalstuff.h" |
25 | #include "gpasmanfile.h" | 25 | #include "gpasmanfile.h" |
26 | #include "serializer.h" | 26 | #include "serializer.h" |
27 | #include "compressgzip.h" | 27 | #include "compressgzip.h" |
28 | //US#include "compressbzip2.h" | 28 | //US#include "compressbzip2.h" |
29 | #include "randomizer.h" | 29 | #include "randomizer.h" |
30 | #include "pwminit.h" | 30 | #include "pwminit.h" |
31 | #include "libgcryptif.h" | 31 | #include "libgcryptif.h" |
32 | #ifdef PWM_EMBEDDED | 32 | #ifdef PWM_EMBEDDED |
33 | #include "pwmprefs.h" | 33 | #include "pwmprefs.h" |
34 | #include "kglobal.h" | 34 | #include "kglobal.h" |
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | #include <kmessagebox.h> | 37 | #include <kmessagebox.h> |
38 | #include <libkcal/syncdefines.h> | 38 | #include <libkcal/syncdefines.h> |
39 | 39 | ||
40 | 40 | ||
41 | #ifdef CONFIG_KWALLETIF | 41 | #ifdef CONFIG_KWALLETIF |
42 | # include "kwalletemu.h" | 42 | # include "kwalletemu.h" |
43 | #endif // CONFIG_KWALLETIF | 43 | #endif // CONFIG_KWALLETIF |
44 | 44 | ||
45 | #include <qdatetime.h> | 45 | #include <qdatetime.h> |
46 | #include <qsize.h> | 46 | #include <qsize.h> |
47 | #include <qfileinfo.h> | 47 | #include <qfileinfo.h> |
48 | #include <qfile.h> | 48 | #include <qfile.h> |
49 | 49 | ||
50 | #include <stdio.h> | 50 | #include <stdio.h> |
51 | #include <stdlib.h> | 51 | #include <stdlib.h> |
52 | #include <errno.h> | 52 | #include <errno.h> |
53 | #include <string.h> | 53 | #include <string.h> |
54 | //US#include <iostream> | 54 | //US#include <iostream> |
55 | #include <algorithm> | 55 | #include <algorithm> |
56 | #include <sys/types.h> | 56 | #include <sys/types.h> |
57 | #include <sys/stat.h> | 57 | #include <sys/stat.h> |
58 | #ifndef _WIN32_ | 58 | #ifndef _WIN32_ |
59 | #include <unistd.h> | 59 | #include <unistd.h> |
60 | #include <stdint.h> | 60 | #include <stdint.h> |
61 | #endif | 61 | #endif |
62 | 62 | ||
63 | #ifdef PWM_EMBEDDED | 63 | #ifdef PWM_EMBEDDED |
64 | #ifndef Q_LONG | 64 | #ifndef Q_LONG |
65 | #define Q_LONG long | 65 | #define Q_LONG long |
66 | #endif | 66 | #endif |
67 | 67 | ||
68 | #ifndef Q_ULONG | 68 | #ifndef Q_ULONG |
69 | #define Q_ULONG unsigned long | 69 | #define Q_ULONG unsigned long |
70 | #endif | 70 | #endif |
71 | #endif //PWM_EMBEDDED | 71 | #endif //PWM_EMBEDDED |
72 | 72 | ||
73 | 73 | ||
74 | //TODO: reset to its normal value. | 74 | //TODO: reset to its normal value. |
75 | //LR set to 5 min | 75 | //LR set to 5 min |
76 | #define META_CHECK_TIMER_INTERVAL300 /* 10 300*/ /* sek */ | 76 | #define META_CHECK_TIMER_INTERVAL300 /* 10 300*/ /* sek */ |
77 | 77 | ||
78 | using namespace std; | 78 | using namespace std; |
79 | 79 | ||
80 | 80 | ||
81 | void PwMDocList::add(PwMDoc *doc, const string &id) | 81 | void PwMDocList::add(PwMDoc *doc, const string &id) |
82 | { | 82 | { |
83 | #ifdef PWM_DEBUG | 83 | #ifdef PWM_DEBUG |
84 | // check for existance of object in debug mode only. | 84 | // check for existance of object in debug mode only. |
85 | vector<listItem>::iterator begin = docList.begin(), | 85 | vector<listItem>::iterator begin = docList.begin(), |
86 | end = docList.end(), | 86 | end = docList.end(), |
87 | i = begin; | 87 | i = begin; |
88 | while (i != end) { | 88 | while (i != end) { |
89 | if (i->doc == doc) { | 89 | if (i->doc == doc) { |
90 | BUG(); | 90 | BUG(); |
91 | return; | 91 | return; |
92 | } | 92 | } |
93 | ++i; | 93 | ++i; |
94 | } | 94 | } |
95 | #endif | 95 | #endif |
96 | listItem newItem; | 96 | listItem newItem; |
97 | newItem.doc = doc; | 97 | newItem.doc = doc; |
98 | newItem.docId = id; | 98 | newItem.docId = id; |
99 | docList.push_back(newItem); | 99 | docList.push_back(newItem); |
100 | } | 100 | } |
101 | 101 | ||
102 | void PwMDocList::edit(PwMDoc *doc, const string &newId) | 102 | void PwMDocList::edit(PwMDoc *doc, const string &newId) |
103 | { | 103 | { |
104 | vector<listItem>::iterator begin = docList.begin(), | 104 | vector<listItem>::iterator begin = docList.begin(), |
105 | end = docList.end(), | 105 | end = docList.end(), |
106 | i = begin; | 106 | i = begin; |
107 | while (i != end) { | 107 | while (i != end) { |
108 | if (i->doc == doc) { | 108 | if (i->doc == doc) { |
109 | i->docId = newId; | 109 | i->docId = newId; |
110 | return; | 110 | return; |
111 | } | 111 | } |
112 | ++i; | 112 | ++i; |
113 | } | 113 | } |
114 | } | 114 | } |
115 | 115 | ||
116 | void PwMDocList::del(PwMDoc *doc) | 116 | void PwMDocList::del(PwMDoc *doc) |
117 | { | 117 | { |
118 | vector<listItem>::iterator begin = docList.begin(), | 118 | vector<listItem>::iterator begin = docList.begin(), |
119 | end = docList.end(), | 119 | end = docList.end(), |
120 | i = begin; | 120 | i = begin; |
121 | while (i != end) { | 121 | while (i != end) { |
122 | if (i->doc == doc) { | 122 | if (i->doc == doc) { |
123 | docList.erase(i); | 123 | docList.erase(i); |
124 | return; | 124 | return; |
125 | } | 125 | } |
126 | ++i; | 126 | ++i; |
127 | } | 127 | } |
128 | } | 128 | } |
129 | 129 | ||
130 | bool PwMDocList::find(const string &id, listItem *ret) | 130 | bool PwMDocList::find(const string &id, listItem *ret) |
131 | { | 131 | { |
132 | vector<listItem>::iterator begin = docList.begin(), | 132 | vector<listItem>::iterator begin = docList.begin(), |
133 | end = docList.end(), | 133 | end = docList.end(), |
134 | i = begin; | 134 | i = begin; |
135 | while (i != end) { | 135 | while (i != end) { |
136 | if (i->docId == id) { | 136 | if (i->docId == id) { |
137 | if (ret) | 137 | if (ret) |
138 | *ret = *i; | 138 | *ret = *i; |
139 | return true; | 139 | return true; |
140 | } | 140 | } |
141 | ++i; | 141 | ++i; |
142 | } | 142 | } |
143 | return false; | 143 | return false; |
144 | } | 144 | } |
145 | 145 | ||
146 | 146 | ||
147 | 147 | ||
148 | DocTimer::DocTimer(PwMDoc *_doc) | 148 | DocTimer::DocTimer(PwMDoc *_doc) |
149 | : doc (_doc) | 149 | : doc (_doc) |
150 | , mpwLock (0) | 150 | , mpwLock (0) |
151 | , autoLockLock (0) | 151 | , autoLockLock (0) |
152 | , metaCheckLock (0) | 152 | , metaCheckLock (0) |
153 | { | 153 | { |
154 | mpwTimer = new QTimer; | 154 | mpwTimer = new QTimer; |
155 | autoLockTimer = new QTimer; | 155 | autoLockTimer = new QTimer; |
156 | metaCheckTimer = new QTimer; | 156 | metaCheckTimer = new QTimer; |
157 | connect(mpwTimer, SIGNAL(timeout()), | 157 | connect(mpwTimer, SIGNAL(timeout()), |
158 | this, SLOT(mpwTimeout())); | 158 | this, SLOT(mpwTimeout())); |
159 | connect(autoLockTimer, SIGNAL(timeout()), | 159 | connect(autoLockTimer, SIGNAL(timeout()), |
160 | this, SLOT(autoLockTimeout())); | 160 | this, SLOT(autoLockTimeout())); |
161 | connect(metaCheckTimer, SIGNAL(timeout()), | 161 | connect(metaCheckTimer, SIGNAL(timeout()), |
162 | this, SLOT(metaCheckTimeout())); | 162 | this, SLOT(metaCheckTimeout())); |
163 | } | 163 | } |
164 | 164 | ||
165 | DocTimer::~DocTimer() | 165 | DocTimer::~DocTimer() |
166 | { | 166 | { |
167 | delete mpwTimer; | 167 | delete mpwTimer; |
168 | delete autoLockTimer; | 168 | delete autoLockTimer; |
169 | delete metaCheckTimer; | 169 | delete metaCheckTimer; |
170 | } | 170 | } |
171 | 171 | ||
172 | void DocTimer::start(TimerIDs timer) | 172 | void DocTimer::start(TimerIDs timer) |
173 | { | 173 | { |
174 | switch (timer) { | 174 | switch (timer) { |
175 | case id_mpwTimer: | 175 | case id_mpwTimer: |
176 | if (mpwTimer->isActive()) | 176 | if (mpwTimer->isActive()) |
177 | mpwTimer->stop(); | 177 | mpwTimer->stop(); |
178 | doc->setDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW); | 178 | doc->setDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW); |
179 | mpwTimer->start(conf()->confGlobPwTimeout() * 1000, true); | 179 | mpwTimer->start(conf()->confGlobPwTimeout() * 1000, true); |
180 | break; | 180 | break; |
181 | case id_autoLockTimer: | 181 | case id_autoLockTimer: |
182 | if (autoLockTimer->isActive()) | 182 | if (autoLockTimer->isActive()) |
183 | autoLockTimer->stop(); | 183 | autoLockTimer->stop(); |
184 | if (conf()->confGlobLockTimeout() > 0) | 184 | if (conf()->confGlobLockTimeout() > 0) |
185 | autoLockTimer->start(conf()->confGlobLockTimeout() * 1000, true); | 185 | autoLockTimer->start(conf()->confGlobLockTimeout() * 1000, true); |
186 | break; | 186 | break; |
187 | case id_metaCheckTimer: | 187 | case id_metaCheckTimer: |
188 | if (metaCheckTimer->isActive()) | 188 | if (metaCheckTimer->isActive()) |
189 | metaCheckTimer->stop(); | 189 | metaCheckTimer->stop(); |
190 | metaCheckTimer->start(META_CHECK_TIMER_INTERVAL * 1000, true); | 190 | metaCheckTimer->start(META_CHECK_TIMER_INTERVAL * 1000, true); |
191 | break; | 191 | break; |
192 | } | 192 | } |
193 | } | 193 | } |
194 | 194 | ||
195 | void DocTimer::stop(TimerIDs timer) | 195 | void DocTimer::stop(TimerIDs timer) |
196 | { | 196 | { |
197 | switch (timer) { | 197 | switch (timer) { |
198 | case id_mpwTimer: | 198 | case id_mpwTimer: |
199 | mpwTimer->stop(); | 199 | mpwTimer->stop(); |
200 | break; | 200 | break; |
201 | case id_autoLockTimer: | 201 | case id_autoLockTimer: |
202 | autoLockTimer->stop(); | 202 | autoLockTimer->stop(); |
203 | break; | 203 | break; |
204 | case id_metaCheckTimer: | 204 | case id_metaCheckTimer: |
205 | metaCheckTimer->stop(); | 205 | metaCheckTimer->stop(); |
206 | break; | 206 | break; |
207 | } | 207 | } |
208 | } | 208 | } |
209 | 209 | ||
210 | void DocTimer::getLock(TimerIDs timer) | 210 | void DocTimer::getLock(TimerIDs timer) |
211 | { | 211 | { |
212 | switch (timer) { | 212 | switch (timer) { |
213 | case id_mpwTimer: | 213 | case id_mpwTimer: |
214 | ++mpwLock; | 214 | ++mpwLock; |
215 | break; | 215 | break; |
216 | case id_autoLockTimer: | 216 | case id_autoLockTimer: |
217 | ++autoLockLock; | 217 | ++autoLockLock; |
218 | break; | 218 | break; |
219 | case id_metaCheckTimer: | 219 | case id_metaCheckTimer: |
220 | ++metaCheckLock; | 220 | ++metaCheckLock; |
221 | break; | 221 | break; |
222 | } | 222 | } |
223 | } | 223 | } |
224 | 224 | ||
225 | void DocTimer::putLock(TimerIDs timer) | 225 | void DocTimer::putLock(TimerIDs timer) |
226 | { | 226 | { |
227 | switch (timer) { | 227 | switch (timer) { |
228 | case id_mpwTimer: | 228 | case id_mpwTimer: |
229 | if (mpwLock) | 229 | if (mpwLock) |
230 | --mpwLock; | 230 | --mpwLock; |
231 | break; | 231 | break; |
232 | case id_autoLockTimer: | 232 | case id_autoLockTimer: |
233 | if (autoLockLock) | 233 | if (autoLockLock) |
234 | --autoLockLock; | 234 | --autoLockLock; |
235 | break; | 235 | break; |
236 | case id_metaCheckTimer: | 236 | case id_metaCheckTimer: |
237 | if (metaCheckLock) | 237 | if (metaCheckLock) |
238 | --metaCheckLock; | 238 | --metaCheckLock; |
239 | break; | 239 | break; |
240 | } | 240 | } |
241 | } | 241 | } |
242 | 242 | ||
243 | void DocTimer::mpwTimeout() | 243 | void DocTimer::mpwTimeout() |
244 | { | 244 | { |
245 | if (mpwLock) { | 245 | if (mpwLock) { |
246 | mpwTimer->start(1000, true); | 246 | mpwTimer->start(1000, true); |
247 | return; | 247 | return; |
248 | } | 248 | } |
249 | doc->unsetDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW); | 249 | doc->unsetDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW); |
250 | } | 250 | } |
251 | 251 | ||
252 | void DocTimer::autoLockTimeout() | 252 | void DocTimer::autoLockTimeout() |
253 | { | 253 | { |
254 | if (autoLockLock) { | 254 | if (autoLockLock) { |
255 | autoLockTimer->start(1000, true); | 255 | autoLockTimer->start(1000, true); |
256 | return; | 256 | return; |
257 | } | 257 | } |
258 | if (conf()->confGlobAutoDeepLock() && | 258 | if (conf()->confGlobAutoDeepLock() && |
259 | doc->filename != QString::null && | 259 | doc->filename != QString::null && |
260 | doc->filename != "") { | 260 | doc->filename != "") { |
261 | doc->deepLock(true); | 261 | doc->deepLock(true); |
262 | } else { | 262 | } else { |
263 | doc->lockAll(true); | 263 | doc->lockAll(true); |
264 | } | 264 | } |
265 | } | 265 | } |
266 | 266 | ||
267 | void DocTimer::metaCheckTimeout() | 267 | void DocTimer::metaCheckTimeout() |
268 | { | 268 | { |
269 | if (metaCheckLock) { | 269 | if (metaCheckLock) { |
270 | // check again in one second. | 270 | // check again in one second. |
271 | metaCheckTimer->start(1000, true); | 271 | metaCheckTimer->start(1000, true); |
272 | return; | 272 | return; |
273 | } | 273 | } |
274 | if (doc->isDeepLocked()) { | 274 | if (doc->isDeepLocked()) { |
275 | metaCheckTimer->start(META_CHECK_TIMER_INTERVAL * 1000, true); | 275 | metaCheckTimer->start(META_CHECK_TIMER_INTERVAL * 1000, true); |
276 | return; | 276 | return; |
277 | } | 277 | } |
278 | if (doc->isDocEmpty()) { | 278 | if (doc->isDocEmpty()) { |
279 | metaCheckTimer->start(META_CHECK_TIMER_INTERVAL * 1000, true); | 279 | metaCheckTimer->start(META_CHECK_TIMER_INTERVAL * 1000, true); |
280 | return; | 280 | return; |
281 | } | 281 | } |
282 | #ifdef CONFIG_KWALLETIF | 282 | #ifdef CONFIG_KWALLETIF |
283 | KWalletEmu *kwlEmu = doc->init->kwalletEmu(); | 283 | KWalletEmu *kwlEmu = doc->init->kwalletEmu(); |
284 | if (kwlEmu) | 284 | if (kwlEmu) |
285 | kwlEmu->suspendDocSignals(); | 285 | kwlEmu->suspendDocSignals(); |
286 | #endif // CONFIG_KWALLETIF | 286 | #endif // CONFIG_KWALLETIF |
287 | /* We simply trigger all views to update their | 287 | /* We simply trigger all views to update their |
288 | * displayed values. This way they have a chance | 288 | * displayed values. This way they have a chance |
289 | * to get notified when some meta changes over time. | 289 | * to get notified when some meta changes over time. |
290 | * (for example an entry expired). | 290 | * (for example an entry expired). |
291 | * The _view_ is responsive for not updating its | 291 | * The _view_ is responsive for not updating its |
292 | * contents if nothing really changed! | 292 | * contents if nothing really changed! |
293 | */ | 293 | */ |
294 | emit doc->dataChanged(doc); | 294 | emit doc->dataChanged(doc); |
295 | #ifdef CONFIG_KWALLETIF | 295 | #ifdef CONFIG_KWALLETIF |
296 | if (kwlEmu) | 296 | if (kwlEmu) |
297 | kwlEmu->resumeDocSignals(); | 297 | kwlEmu->resumeDocSignals(); |
298 | #endif // CONFIG_KWALLETIF | 298 | #endif // CONFIG_KWALLETIF |
299 | metaCheckTimer->start(META_CHECK_TIMER_INTERVAL * 1000, true); | 299 | metaCheckTimer->start(META_CHECK_TIMER_INTERVAL * 1000, true); |
300 | } | 300 | } |
301 | 301 | ||
302 | 302 | ||
303 | 303 | ||
304 | PwMDocList PwMDoc::openDocList; | 304 | PwMDocList PwMDoc::openDocList; |
305 | unsigned int PwMDocList::unnamedDocCnt = 1; | 305 | unsigned int PwMDocList::unnamedDocCnt = 1; |
306 | 306 | ||
307 | PwMDoc::PwMDoc(QObject *parent, const char *name) | 307 | PwMDoc::PwMDoc(QObject *parent, const char *name) |
308 | : PwMDocUi(parent, name) | 308 | : PwMDocUi(parent, name) |
309 | , dataChangedLock (0) | 309 | , dataChangedLock (0) |
310 | { | 310 | { |
311 | deleted = false; | 311 | deleted = false; |
312 | unnamedNum = 0; | 312 | unnamedNum = 0; |
313 | getOpenDocList()->add(this, getTitle().latin1()); | 313 | getOpenDocList()->add(this, getTitle().latin1()); |
314 | curDocStat = 0; | 314 | curDocStat = 0; |
315 | setMaxNumEntries(); | 315 | setMaxNumEntries(); |
316 | _timer = new DocTimer(this); | 316 | _timer = new DocTimer(this); |
317 | timer()->start(DocTimer::id_mpwTimer); | 317 | timer()->start(DocTimer::id_mpwTimer); |
318 | timer()->start(DocTimer::id_autoLockTimer); | 318 | timer()->start(DocTimer::id_autoLockTimer); |
319 | timer()->start(DocTimer::id_metaCheckTimer); | 319 | timer()->start(DocTimer::id_metaCheckTimer); |
320 | addCategory(DEFAULT_CATEGORY, 0, false); | 320 | addCategory(DEFAULT_CATEGORY, 0, false); |
321 | listView = 0; | 321 | listView = 0; |
322 | emit docCreated(this); | 322 | emit docCreated(this); |
323 | } | 323 | } |
324 | 324 | ||
325 | PwMDoc::~PwMDoc() | 325 | PwMDoc::~PwMDoc() |
326 | { | 326 | { |
327 | emit docClosed(this); | 327 | emit docClosed(this); |
328 | getOpenDocList()->del(this); | 328 | getOpenDocList()->del(this); |
329 | delete _timer; | 329 | delete _timer; |
330 | } | 330 | } |
331 | 331 | ||
332 | PwMerror PwMDoc::saveDoc(char compress, const QString *file) | 332 | PwMerror PwMDoc::saveDoc(char compress, const QString *file) |
333 | { | 333 | { |
334 | PwMerror ret, e; | 334 | PwMerror ret, e; |
335 | string serialized; | 335 | string serialized; |
336 | QFile f; | 336 | QFile f; |
337 | QString tmpFileMoved(QString::null); | 337 | QString tmpFileMoved(QString::null); |
338 | bool wasDeepLocked; | 338 | bool wasDeepLocked; |
339 | QString savedFilename(filename); | 339 | QString savedFilename(filename); |
340 | 340 | ||
341 | if (!file) { | 341 | if (!file) { |
342 | if (filename == "") | 342 | if (filename == "") |
343 | return e_filename; | 343 | return e_filename; |
344 | if (isDeepLocked()) { | 344 | if (isDeepLocked()) { |
345 | /* We don't need to save any data. | 345 | /* We don't need to save any data. |
346 | * It's already all on disk, because | 346 | * It's already all on disk, because |
347 | * we are deeplocked. | 347 | * we are deeplocked. |
348 | */ | 348 | */ |
349 | unsetDocStatFlag(DOC_STAT_DISK_DIRTY); | 349 | unsetDocStatFlag(DOC_STAT_DISK_DIRTY); |
350 | ret = e_success; | 350 | ret = e_success; |
351 | return ret; | 351 | return ret; |
352 | } | 352 | } |
353 | } else { | 353 | } else { |
354 | if (*file == "" && filename == "") | 354 | if (*file == "" && filename == "") |
355 | return e_filename; | 355 | return e_filename; |
356 | if (*file != "") | 356 | if (*file != "") |
357 | filename = *file; | 357 | filename = *file; |
358 | } | 358 | } |
359 | 359 | ||
360 | wasDeepLocked = isDeepLocked(); | 360 | wasDeepLocked = isDeepLocked(); |
361 | if (wasDeepLocked) { | 361 | if (wasDeepLocked) { |
362 | /* We are deeplocked. That means all data is already | 362 | /* We are deeplocked. That means all data is already |
363 | * on disk. BUT we need to do saving procedure, | 363 | * on disk. BUT we need to do saving procedure, |
364 | * because *file != savedFilename. | 364 | * because *file != savedFilename. |
365 | * Additionally we need to tempoarly restore | 365 | * Additionally we need to tempoarly restore |
366 | * the old "filename", because deepLock() references it. | 366 | * the old "filename", because deepLock() references it. |
367 | */ | 367 | */ |
368 | QString newFilename(filename); | 368 | QString newFilename(filename); |
369 | filename = savedFilename; | 369 | filename = savedFilename; |
370 | getDataChangedLock(); | 370 | getDataChangedLock(); |
371 | e = deepLock(false); | 371 | e = deepLock(false); |
372 | putDataChangedLock(); | 372 | putDataChangedLock(); |
373 | filename = newFilename; | 373 | filename = newFilename; |
374 | switch (e) { | 374 | switch (e) { |
375 | case e_success: | 375 | case e_success: |
376 | break; | 376 | break; |
377 | case e_wrongPw: | 377 | case e_wrongPw: |
378 | case e_noPw: | 378 | case e_noPw: |
379 | emitDataChanged(this); | 379 | emitDataChanged(this); |
380 | return e; | 380 | return e; |
381 | default: | 381 | default: |
382 | emitDataChanged(this); | 382 | emitDataChanged(this); |
383 | return e_openFile; | 383 | return e_openFile; |
384 | } | 384 | } |
385 | } | 385 | } |
386 | 386 | ||
387 | if (!isPwAvailable()) { | 387 | if (!isPwAvailable()) { |
388 | /* password is not available. This means, the | 388 | /* password is not available. This means, the |
389 | * document wasn't saved, yet. | 389 | * document wasn't saved, yet. |
390 | */ | 390 | */ |
391 | bool useChipcard = getDocStatFlag(DOC_STAT_USE_CHIPCARD); | 391 | bool useChipcard = getDocStatFlag(DOC_STAT_USE_CHIPCARD); |
392 | QString pw(requestNewMpw(&useChipcard)); | 392 | QString pw(requestNewMpw(&useChipcard)); |
393 | if (pw != "") { | 393 | if (pw != "") { |
394 | currentPw = pw; | 394 | currentPw = pw; |
395 | } else { | 395 | } else { |
396 | return e_noPw; | 396 | return e_noPw; |
397 | } | 397 | } |
398 | if (useChipcard) { | 398 | if (useChipcard) { |
399 | setDocStatFlag(DOC_STAT_USE_CHIPCARD); | 399 | setDocStatFlag(DOC_STAT_USE_CHIPCARD); |
400 | } else { | 400 | } else { |
401 | unsetDocStatFlag(DOC_STAT_USE_CHIPCARD); | 401 | unsetDocStatFlag(DOC_STAT_USE_CHIPCARD); |
402 | } | 402 | } |
403 | } | 403 | } |
404 | 404 | ||
405 | int _cryptAlgo = conf()->confGlobCryptAlgo(); | 405 | int _cryptAlgo = conf()->confGlobCryptAlgo(); |
406 | int _hashAlgo = conf()->confGlobHashAlgo(); | 406 | int _hashAlgo = conf()->confGlobHashAlgo(); |
407 | 407 | ||
408 | // sanity check for the selected algorithms | 408 | // sanity check for the selected algorithms |
409 | if (_cryptAlgo < PWM_CRYPT_BLOWFISH || | 409 | if (_cryptAlgo < PWM_CRYPT_BLOWFISH || |
410 | _cryptAlgo > PWM_CRYPT_TWOFISH128) { | 410 | _cryptAlgo > PWM_CRYPT_TWOFISH128) { |
411 | printWarn("Invalid Crypto-Algorithm selected! " | 411 | printWarn("Invalid Crypto-Algorithm selected! " |
412 | "Config-file seems to be corrupt. " | 412 | "Config-file seems to be corrupt. " |
413 | "Falling back to Blowfish."); | 413 | "Falling back to Blowfish."); |
414 | _cryptAlgo = PWM_CRYPT_BLOWFISH; | 414 | _cryptAlgo = PWM_CRYPT_BLOWFISH; |
415 | } | 415 | } |
416 | if (_hashAlgo < PWM_HASH_SHA1 || | 416 | if (_hashAlgo < PWM_HASH_SHA1 || |
417 | _hashAlgo > PWM_HASH_TIGER) { | 417 | _hashAlgo > PWM_HASH_TIGER) { |
418 | printWarn("Invalid Hash-Algorithm selected! " | 418 | printWarn("Invalid Hash-Algorithm selected! " |
419 | "Config-file seems to be corrupt. " | 419 | "Config-file seems to be corrupt. " |
420 | "Falling back to SHA1."); | 420 | "Falling back to SHA1."); |
421 | _hashAlgo = PWM_HASH_SHA1; | 421 | _hashAlgo = PWM_HASH_SHA1; |
422 | } | 422 | } |
423 | char cryptAlgo = static_cast<char>(_cryptAlgo); | 423 | char cryptAlgo = static_cast<char>(_cryptAlgo); |
424 | char hashAlgo = static_cast<char>(_hashAlgo); | 424 | char hashAlgo = static_cast<char>(_hashAlgo); |
425 | 425 | ||
426 | if (conf()->confGlobMakeFileBackup()) { | 426 | if (conf()->confGlobMakeFileBackup()) { |
427 | if (!backupFile(filename)) | 427 | if (!backupFile(filename)) |
428 | return e_fileBackup; | 428 | return e_fileBackup; |
429 | } | 429 | } |
430 | if (QFile::exists(filename)) { | 430 | if (QFile::exists(filename)) { |
431 | /* Move the existing file to some tmp file. | 431 | /* Move the existing file to some tmp file. |
432 | * When saving file succeeds, delete tmp file. Otherwise | 432 | * When saving file succeeds, delete tmp file. Otherwise |
433 | * move tmp file back. See below. | 433 | * move tmp file back. See below. |
434 | */ | 434 | */ |
435 | Randomizer *rnd = Randomizer::obj(); | 435 | Randomizer *rnd = Randomizer::obj(); |
436 | char rnd_buf[5]; | 436 | char rnd_buf[5]; |
437 | sprintf(rnd_buf, "%X%X%X%X", rnd->genRndChar() & 0xFF, rnd->genRndChar() & 0xFF, | 437 | sprintf(rnd_buf, "%X%X%X%X", rnd->genRndChar() & 0xFF, rnd->genRndChar() & 0xFF, |
438 | rnd->genRndChar() & 0xFF, rnd->genRndChar() & 0xFF); | 438 | rnd->genRndChar() & 0xFF, rnd->genRndChar() & 0xFF); |
439 | tmpFileMoved = filename + "." + rnd_buf + ".mv"; | 439 | tmpFileMoved = filename + "." + rnd_buf + ".mv"; |
440 | if (!copyFile(filename, tmpFileMoved)) | 440 | if (!copyFile(filename, tmpFileMoved)) |
441 | return e_openFile; | 441 | return e_openFile; |
442 | if (!QFile::remove(filename)) { | 442 | if (!QFile::remove(filename)) { |
443 | printWarn(string("removing orig file ") | 443 | printWarn(string("removing orig file ") |
444 | + filename.latin1() | 444 | + filename.latin1() |
445 | + " failed!"); | 445 | + " failed!"); |
446 | } | 446 | } |
447 | } | 447 | } |
448 | f.setName(filename); | 448 | f.setName(filename); |
449 | if (!f.open(IO_ReadWrite)) { | 449 | if (!f.open(IO_ReadWrite)) { |
450 | ret = e_openFile; | 450 | ret = e_openFile; |
451 | goto out_moveback; | 451 | goto out_moveback; |
452 | } | 452 | } |
453 | e = writeFileHeader(hashAlgo, hashAlgo, | 453 | e = writeFileHeader(hashAlgo, hashAlgo, |
454 | cryptAlgo, compress, | 454 | cryptAlgo, compress, |
455 | ¤tPw, &f); | 455 | ¤tPw, &f); |
456 | if (e == e_hashNotImpl) { | 456 | if (e == e_hashNotImpl) { |
457 | printDebug("PwMDoc::saveDoc(): writeFileHeader() failed: e_hashNotImpl"); | 457 | printDebug("PwMDoc::saveDoc(): writeFileHeader() failed: e_hashNotImpl"); |
458 | f.close(); | 458 | f.close(); |
459 | ret = e_hashNotImpl; | 459 | ret = e_hashNotImpl; |
460 | goto out_moveback; | 460 | goto out_moveback; |
461 | } else if (e != e_success) { | 461 | } else if (e != e_success) { |
462 | printDebug("PwMDoc::saveDoc(): writeFileHeader() failed"); | 462 | printDebug("PwMDoc::saveDoc(): writeFileHeader() failed"); |
463 | f.close(); | 463 | f.close(); |
464 | ret = e_writeHeader; | 464 | ret = e_writeHeader; |
465 | goto out_moveback; | 465 | goto out_moveback; |
466 | } | 466 | } |
467 | if (!serializeDta(&serialized)) { | 467 | if (!serializeDta(&serialized)) { |
468 | printDebug("PwMDoc::saveDoc(): serializeDta() failed"); | 468 | printDebug("PwMDoc::saveDoc(): serializeDta() failed"); |
469 | f.close(); | 469 | f.close(); |
470 | ret = e_serializeDta; | 470 | ret = e_serializeDta; |
471 | goto out_moveback; | 471 | goto out_moveback; |
472 | } | 472 | } |
473 | e = writeDataHash(hashAlgo, &serialized, &f); | 473 | e = writeDataHash(hashAlgo, &serialized, &f); |
474 | if (e == e_hashNotImpl) { | 474 | if (e == e_hashNotImpl) { |
475 | printDebug("PwMDoc::saveDoc(): writeDataHash() failed: e_hashNotImpl"); | 475 | printDebug("PwMDoc::saveDoc(): writeDataHash() failed: e_hashNotImpl"); |
476 | f.close(); | 476 | f.close(); |
477 | ret = e_hashNotImpl; | 477 | ret = e_hashNotImpl; |
478 | goto out_moveback; | 478 | goto out_moveback; |
479 | } else if (e != e_success) { | 479 | } else if (e != e_success) { |
480 | printDebug("PwMDoc::saveDoc(): writeDataHash() failed"); | 480 | printDebug("PwMDoc::saveDoc(): writeDataHash() failed"); |
481 | f.close(); | 481 | f.close(); |
482 | ret = e_writeHeader; | 482 | ret = e_writeHeader; |
483 | goto out_moveback; | 483 | goto out_moveback; |
484 | } | 484 | } |
485 | if (!compressDta(&serialized, compress)) { | 485 | if (!compressDta(&serialized, compress)) { |
486 | printDebug("PwMDoc::saveDoc(): compressDta() failed"); | 486 | printDebug("PwMDoc::saveDoc(): compressDta() failed"); |
487 | f.close(); | 487 | f.close(); |
488 | ret = e_enc; | 488 | ret = e_enc; |
489 | goto out_moveback; | 489 | goto out_moveback; |
490 | } | 490 | } |
491 | e = encrypt(&serialized, ¤tPw, &f, cryptAlgo, hashAlgo); | 491 | e = encrypt(&serialized, ¤tPw, &f, cryptAlgo, hashAlgo); |
492 | if (e == e_weakPw) { | 492 | if (e == e_weakPw) { |
493 | printDebug("PwMDoc::saveDoc(): encrypt() failed: e_weakPw"); | 493 | printDebug("PwMDoc::saveDoc(): encrypt() failed: e_weakPw"); |
494 | f.close(); | 494 | f.close(); |
495 | ret = e_weakPw; | 495 | ret = e_weakPw; |
496 | goto out_moveback; | 496 | goto out_moveback; |
497 | } else if (e == e_cryptNotImpl) { | 497 | } else if (e == e_cryptNotImpl) { |
498 | printDebug("PwMDoc::saveDoc(): encrypt() failed: e_cryptNotImpl"); | 498 | printDebug("PwMDoc::saveDoc(): encrypt() failed: e_cryptNotImpl"); |
499 | f.close(); | 499 | f.close(); |
500 | ret = e_cryptNotImpl; | 500 | ret = e_cryptNotImpl; |
501 | goto out_moveback; | 501 | goto out_moveback; |
502 | } else if (e != e_success) { | 502 | } else if (e != e_success) { |
503 | printDebug("PwMDoc::saveDoc(): encrypt() failed"); | 503 | printDebug("PwMDoc::saveDoc(): encrypt() failed"); |
504 | f.close(); | 504 | f.close(); |
505 | ret = e_enc; | 505 | ret = e_enc; |
506 | goto out_moveback; | 506 | goto out_moveback; |
507 | } | 507 | } |
508 | unsetDocStatFlag(DOC_STAT_DISK_DIRTY); | 508 | unsetDocStatFlag(DOC_STAT_DISK_DIRTY); |
509 | f.close(); | 509 | f.close(); |
510 | #ifndef _WIN32_ | 510 | #ifndef _WIN32_ |
511 | if (chmod(filename.latin1(), | 511 | if (chmod(filename.latin1(), |
512 | conf()->confGlobFilePermissions())) { | 512 | conf()->confGlobFilePermissions())) { |
513 | printWarn(string("chmod failed: ") + strerror(errno)); | 513 | printWarn(string("chmod failed: ") + strerror(errno)); |
514 | } | 514 | } |
515 | #endif | 515 | #endif |
516 | openDocList.edit(this, getTitle().latin1()); | 516 | openDocList.edit(this, getTitle().latin1()); |
517 | if (wasDeepLocked) { | 517 | if (wasDeepLocked) { |
518 | /* Do _not_ save the data with the deepLock() | 518 | /* Do _not_ save the data with the deepLock() |
519 | * call, because this will recurse | 519 | * call, because this will recurse |
520 | * into saveDoc() | 520 | * into saveDoc() |
521 | */ | 521 | */ |
522 | deepLock(true, false); | 522 | deepLock(true, false); |
523 | /* We don't check return value here, because | 523 | /* We don't check return value here, because |
524 | * it won't fail. See NOTE in deepLock() | 524 | * it won't fail. See NOTE in deepLock() |
525 | */ | 525 | */ |
526 | } | 526 | } |
527 | if (tmpFileMoved != QString::null) { | 527 | if (tmpFileMoved != QString::null) { |
528 | // now remove the moved file. | 528 | // now remove the moved file. |
529 | if (!QFile::remove(tmpFileMoved)) { | 529 | if (!QFile::remove(tmpFileMoved)) { |
530 | printWarn(string("removing file ") | 530 | printWarn(string("removing file ") |
531 | + tmpFileMoved.latin1() | 531 | + tmpFileMoved.latin1() |
532 | + " failed!"); | 532 | + " failed!"); |
533 | } | 533 | } |
534 | } | 534 | } |
535 | ret = e_success; | 535 | ret = e_success; |
536 | printDebug(string("writing file { name: ") | 536 | printDebug(string("writing file { name: ") |
537 | + filename.latin1() + " compress: " | 537 | + filename.latin1() + " compress: " |
538 | + tostr(static_cast<int>(compress)) + " cryptAlgo: " | 538 | + tostr(static_cast<int>(compress)) + " cryptAlgo: " |
539 | + tostr(static_cast<int>(cryptAlgo)) + " hashAlgo: " | 539 | + tostr(static_cast<int>(cryptAlgo)) + " hashAlgo: " |
540 | + tostr(static_cast<int>(hashAlgo)) | 540 | + tostr(static_cast<int>(hashAlgo)) |
541 | + " }"); | 541 | + " }"); |
542 | goto out; | 542 | goto out; |
543 | out_moveback: | 543 | out_moveback: |
544 | if (tmpFileMoved != QString::null) { | 544 | if (tmpFileMoved != QString::null) { |
545 | if (copyFile(tmpFileMoved, filename)) { | 545 | if (copyFile(tmpFileMoved, filename)) { |
546 | if (!QFile::remove(tmpFileMoved)) { | 546 | if (!QFile::remove(tmpFileMoved)) { |
547 | printWarn(string("removing tmp file ") | 547 | printWarn(string("removing tmp file ") |
548 | + filename.latin1() | 548 | + filename.latin1() |
549 | + " failed!"); | 549 | + " failed!"); |
550 | } | 550 | } |
551 | } else { | 551 | } else { |
552 | printWarn(string("couldn't copy file ") | 552 | printWarn(string("couldn't copy file ") |
553 | + tmpFileMoved.latin1() | 553 | + tmpFileMoved.latin1() |
554 | + " back to " | 554 | + " back to " |
555 | + filename.latin1()); | 555 | + filename.latin1()); |
556 | } | 556 | } |
557 | } | 557 | } |
558 | out: | 558 | out: |
559 | return ret; | 559 | return ret; |
560 | } | 560 | } |
561 | 561 | ||
562 | PwMerror PwMDoc::openDoc(const QString *file, int openLocked) | 562 | PwMerror PwMDoc::openDoc(const QString *file, int openLocked) |
563 | { | 563 | { |
564 | PWM_ASSERT(file); | 564 | PWM_ASSERT(file); |
565 | PWM_ASSERT(openLocked == 0 || openLocked == 1 || openLocked == 2); | 565 | PWM_ASSERT(openLocked == 0 || openLocked == 1 || openLocked == 2); |
566 | string decrypted, dataHash; | 566 | string decrypted, dataHash; |
567 | PwMerror ret; | 567 | PwMerror ret; |
568 | char cryptAlgo, dataHashType, compress; | 568 | char cryptAlgo, dataHashType, compress; |
569 | unsigned int headerLen; | 569 | unsigned int headerLen; |
570 | 570 | ||
571 | if (*file == "") | 571 | if (*file == "") |
572 | return e_readFile; | 572 | return e_readFile; |
573 | filename = *file; | 573 | filename = *file; |
574 | /* check if this file is already open. | 574 | /* check if this file is already open. |
575 | * This does not catch symlinks! | 575 | * This does not catch symlinks! |
576 | */ | 576 | */ |
577 | if (!isDeepLocked()) { | 577 | if (!isDeepLocked()) { |
578 | if (getOpenDocList()->find(filename.latin1())) | 578 | if (getOpenDocList()->find(filename.latin1())) |
579 | return e_alreadyOpen; | 579 | return e_alreadyOpen; |
580 | } | 580 | } |
581 | QFile f(filename); | 581 | QFile f(filename); |
582 | 582 | ||
583 | if (openLocked == 2) { | 583 | if (openLocked == 2) { |
584 | // open deep-locked | 584 | // open deep-locked |
585 | if (!QFile::exists(filename)) | 585 | if (!QFile::exists(filename)) |
586 | return e_openFile; | 586 | return e_openFile; |
587 | if (deepLock(true, false) != e_success) | 587 | if (deepLock(true, false) != e_success) |
588 | return e_openFile; | 588 | return e_openFile; |
589 | goto out_success; | 589 | goto out_success; |
590 | } | 590 | } |
591 | 591 | ||
592 | if (!f.open(IO_ReadOnly)) | 592 | if (!f.open(IO_ReadOnly)) |
593 | return e_openFile; | 593 | return e_openFile; |
594 | 594 | ||
595 | ret = checkHeader(&cryptAlgo, ¤tPw, &compress, &headerLen, | 595 | ret = checkHeader(&cryptAlgo, ¤tPw, &compress, &headerLen, |
596 | &dataHashType, &dataHash, &f); | 596 | &dataHashType, &dataHash, &f); |
597 | if (ret != e_success) { | 597 | if (ret != e_success) { |
598 | printDebug("PwMDoc::openDoc(): checkHeader() failed"); | 598 | printDebug("PwMDoc::openDoc(): checkHeader() failed"); |
599 | f.close(); | 599 | f.close(); |
600 | if (ret == e_wrongPw) { | 600 | if (ret == e_wrongPw) { |
601 | wrongMpwMsgBox(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); | 601 | wrongMpwMsgBox(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); |
602 | return ret; | 602 | return ret; |
603 | } else if (ret == e_noPw || | 603 | } else if (ret == e_noPw || |
604 | ret == e_fileVer || | 604 | ret == e_fileVer || |
605 | ret == e_fileFormat || | 605 | ret == e_fileFormat || |
606 | ret == e_hashNotImpl) { | 606 | ret == e_hashNotImpl) { |
607 | return ret; | 607 | return ret; |
608 | } else | 608 | } else |
609 | return e_readFile; | 609 | return e_readFile; |
610 | } | 610 | } |
611 | ret = decrypt(&decrypted, headerLen, ¤tPw, cryptAlgo, dataHashType, &f); | 611 | ret = decrypt(&decrypted, headerLen, ¤tPw, cryptAlgo, dataHashType, &f); |
612 | if (ret == e_cryptNotImpl) { | 612 | if (ret == e_cryptNotImpl) { |
613 | printDebug("PwMDoc::openDoc(): decrypt() failed: e_cryptNotImpl"); | 613 | printDebug("PwMDoc::openDoc(): decrypt() failed: e_cryptNotImpl"); |
614 | f.close(); | 614 | f.close(); |
615 | return e_cryptNotImpl; | 615 | return e_cryptNotImpl; |
616 | } else if (ret != e_success) { | 616 | } else if (ret != e_success) { |
617 | printDebug("PwMDoc::openDoc(): decrypt() failed"); | 617 | printDebug("PwMDoc::openDoc(): decrypt() failed"); |
618 | f.close(); | 618 | f.close(); |
619 | return e_readFile; | 619 | return e_readFile; |
620 | } | 620 | } |
621 | if (!decompressDta(&decrypted, compress)) { | 621 | if (!decompressDta(&decrypted, compress)) { |
622 | printDebug("PwMDoc::openDoc(): decompressDta() failed"); | 622 | printDebug("PwMDoc::openDoc(): decompressDta() failed"); |
623 | f.close(); | 623 | f.close(); |
624 | return e_fileCorrupt; | 624 | return e_fileCorrupt; |
625 | } | 625 | } |
626 | ret = checkDataHash(dataHashType, &dataHash, &decrypted); | 626 | ret = checkDataHash(dataHashType, &dataHash, &decrypted); |
627 | if (ret == e_hashNotImpl) { | 627 | if (ret == e_hashNotImpl) { |
628 | printDebug("PwMDoc::openDoc(): checkDataHash() failed: e_hashNotImpl"); | 628 | printDebug("PwMDoc::openDoc(): checkDataHash() failed: e_hashNotImpl"); |
629 | f.close(); | 629 | f.close(); |
630 | return e_hashNotImpl; | 630 | return e_hashNotImpl; |
631 | } else if (ret != e_success) { | 631 | } else if (ret != e_success) { |
632 | printDebug("PwMDoc::openDoc(): checkDataHash() failed"); | 632 | printDebug("PwMDoc::openDoc(): checkDataHash() failed"); |
633 | f.close(); | 633 | f.close(); |
634 | return e_fileCorrupt; | 634 | return e_fileCorrupt; |
635 | } | 635 | } |
636 | if (!deSerializeDta(&decrypted, openLocked == 1)) { | 636 | if (!deSerializeDta(&decrypted, openLocked == 1)) { |
637 | printDebug("PwMDoc::openDoc(): deSerializeDta() failed"); | 637 | printDebug("PwMDoc::openDoc(): deSerializeDta() failed"); |
638 | f.close(); | 638 | f.close(); |
639 | return e_readFile; | 639 | return e_readFile; |
640 | } | 640 | } |
641 | f.close(); | 641 | f.close(); |
642 | timer()->start(DocTimer::id_mpwTimer); | 642 | timer()->start(DocTimer::id_mpwTimer); |
643 | timer()->start(DocTimer::id_autoLockTimer); | 643 | timer()->start(DocTimer::id_autoLockTimer); |
644 | out_success: | 644 | out_success: |
645 | openDocList.edit(this, getTitle().latin1()); | 645 | openDocList.edit(this, getTitle().latin1()); |
646 | emit docOpened(this); | 646 | emit docOpened(this); |
647 | return e_success; | 647 | return e_success; |
648 | } | 648 | } |
649 | 649 | ||
650 | PwMerror PwMDoc::writeFileHeader(char keyHash, char dataHash, char crypt, char compress, | 650 | PwMerror PwMDoc::writeFileHeader(char keyHash, char dataHash, char crypt, char compress, |
651 | QString *pw, QFile *f) | 651 | QString *pw, QFile *f) |
652 | { | 652 | { |
653 | PWM_ASSERT(pw); | 653 | PWM_ASSERT(pw); |
654 | PWM_ASSERT(f); | 654 | PWM_ASSERT(f); |
655 | //US ENH: or maybe a bug: checking here for listView does not make sense because we do not check anywhere else | 655 | //US ENH: or maybe a bug: checking here for listView does not make sense because we do not check anywhere else |
656 | //Wenn I sync, I open a doc without a view => listView is 0 => Assertion | 656 | //Wenn I sync, I open a doc without a view => listView is 0 => Assertion |
657 | //USPWM_ASSERT(listView); | 657 | //USPWM_ASSERT(listView); |
658 | if (f->writeBlock(FILE_ID_HEADER, strlen(FILE_ID_HEADER)) != | 658 | if (f->writeBlock(FILE_ID_HEADER, strlen(FILE_ID_HEADER)) != |
659 | static_cast<Q_LONG>(strlen(FILE_ID_HEADER))) { | 659 | static_cast<Q_LONG>(strlen(FILE_ID_HEADER))) { |
660 | return e_writeFile; | 660 | return e_writeFile; |
661 | } | 661 | } |
662 | if (f->putch(PWM_FILE_VER) == -1 || | 662 | if (f->putch(PWM_FILE_VER) == -1 || |
663 | f->putch(keyHash) == -1 || | 663 | f->putch(keyHash) == -1 || |
664 | f->putch(dataHash) == -1 || | 664 | f->putch(dataHash) == -1 || |
665 | f->putch(crypt) == -1 || | 665 | f->putch(crypt) == -1 || |
666 | f->putch(compress) == -1 || | 666 | f->putch(compress) == -1 || |
667 | f->putch((getDocStatFlag(DOC_STAT_USE_CHIPCARD)) ? | 667 | f->putch((getDocStatFlag(DOC_STAT_USE_CHIPCARD)) ? |
668 | (static_cast<char>(0x01)) : (static_cast<char>(0x00))) == -1) { | 668 | (static_cast<char>(0x01)) : (static_cast<char>(0x00))) == -1) { |
669 | return e_writeFile; | 669 | return e_writeFile; |
670 | } | 670 | } |
671 | 671 | ||
672 | // write bytes of NUL-data. These bytes are reserved for future-use. | 672 | // write bytes of NUL-data. These bytes are reserved for future-use. |
673 | const int bufSize = 64; | 673 | const int bufSize = 64; |
674 | char tmp_buf[bufSize]; | 674 | char tmp_buf[bufSize]; |
675 | memset(tmp_buf, 0x00, bufSize); | 675 | memset(tmp_buf, 0x00, bufSize); |
676 | if (f->writeBlock(tmp_buf, bufSize) != bufSize) | 676 | if (f->writeBlock(tmp_buf, bufSize) != bufSize) |
677 | return e_writeFile; | 677 | return e_writeFile; |
678 | 678 | ||
679 | switch (keyHash) { | 679 | switch (keyHash) { |
680 | case PWM_HASH_SHA1: { | 680 | case PWM_HASH_SHA1: { |
681 | const int hashlen = SHA1_HASH_LEN_BYTE; | 681 | const int hashlen = SHA1_HASH_LEN_BYTE; |
682 | Sha1 hash; | 682 | Sha1 hash; |
683 | hash.sha1_write(reinterpret_cast<const byte *>(pw->latin1()), pw->length()); | 683 | hash.sha1_write(reinterpret_cast<const byte *>(pw->latin1()), pw->length()); |
684 | string ret = hash.sha1_read(); | 684 | string ret = hash.sha1_read(); |
685 | if (f->writeBlock(ret.c_str(), hashlen) != hashlen) | 685 | if (f->writeBlock(ret.c_str(), hashlen) != hashlen) |
686 | return e_writeFile; | 686 | return e_writeFile; |
687 | break; | 687 | break; |
688 | } | 688 | } |
689 | case PWM_HASH_SHA256: | 689 | case PWM_HASH_SHA256: |
690 | /*... fall through */ | 690 | /*... fall through */ |
691 | case PWM_HASH_SHA384: | 691 | case PWM_HASH_SHA384: |
692 | case PWM_HASH_SHA512: | 692 | case PWM_HASH_SHA512: |
693 | case PWM_HASH_MD5: | 693 | case PWM_HASH_MD5: |
694 | case PWM_HASH_RMD160: | 694 | case PWM_HASH_RMD160: |
695 | case PWM_HASH_TIGER: | 695 | case PWM_HASH_TIGER: |
696 | { | 696 | { |
697 | if (!LibGCryptIf::available()) | 697 | if (!LibGCryptIf::available()) |
698 | return e_hashNotImpl; | 698 | return e_hashNotImpl; |
699 | LibGCryptIf gc; | 699 | LibGCryptIf gc; |
700 | PwMerror err; | 700 | PwMerror err; |
701 | unsigned char *buf; | 701 | unsigned char *buf; |
702 | size_t hashLen; | 702 | size_t hashLen; |
703 | err = gc.hash(&buf, | 703 | err = gc.hash(&buf, |
704 | &hashLen, | 704 | &hashLen, |
705 | reinterpret_cast<const unsigned char *>(pw->latin1()), | 705 | reinterpret_cast<const unsigned char *>(pw->latin1()), |
706 | pw->length(), | 706 | pw->length(), |
707 | keyHash); | 707 | keyHash); |
708 | if (err != e_success) | 708 | if (err != e_success) |
709 | return e_hashNotImpl; | 709 | return e_hashNotImpl; |
710 | if (f->writeBlock(reinterpret_cast<const char *>(buf), hashLen) | 710 | if (f->writeBlock(reinterpret_cast<const char *>(buf), hashLen) |
711 | != static_cast<Q_LONG>(hashLen)) { | 711 | != static_cast<Q_LONG>(hashLen)) { |
712 | delete [] buf; | 712 | delete [] buf; |
713 | return e_hashNotImpl; | 713 | return e_hashNotImpl; |
714 | } | 714 | } |
715 | delete [] buf; | 715 | delete [] buf; |
716 | break; | 716 | break; |
717 | } | 717 | } |
718 | default: { | 718 | default: { |
719 | return e_hashNotImpl; | 719 | return e_hashNotImpl; |
720 | } } | 720 | } } |
721 | return e_success; | 721 | return e_success; |
722 | } | 722 | } |
723 | 723 | ||
724 | PwMerror PwMDoc::checkHeader(char *cryptAlgo, QString *pw, char *compress, | 724 | PwMerror PwMDoc::checkHeader(char *cryptAlgo, QString *pw, char *compress, |
725 | unsigned int *headerLength, char *dataHashType, | 725 | unsigned int *headerLength, char *dataHashType, |
726 | string *dataHash, QFile *f) | 726 | string *dataHash, QFile *f) |
727 | { | 727 | { |
728 | PWM_ASSERT(cryptAlgo); | 728 | PWM_ASSERT(cryptAlgo); |
729 | PWM_ASSERT(pw); | 729 | PWM_ASSERT(pw); |
730 | PWM_ASSERT(headerLength); | 730 | PWM_ASSERT(headerLength); |
731 | PWM_ASSERT(dataHashType); | 731 | PWM_ASSERT(dataHashType); |
732 | PWM_ASSERT(dataHash); | 732 | PWM_ASSERT(dataHash); |
733 | PWM_ASSERT(f); | 733 | PWM_ASSERT(f); |
734 | int tmpRet; | 734 | int tmpRet; |
735 | // check "magic" header | 735 | // check "magic" header |
736 | const char magicHdr[] = FILE_ID_HEADER; | 736 | const char magicHdr[] = FILE_ID_HEADER; |
737 | const int hdrLen = array_size(magicHdr) - 1; | 737 | const int hdrLen = array_size(magicHdr) - 1; |
738 | char tmp[hdrLen]; | 738 | char tmp[hdrLen]; |
739 | if (f->readBlock(tmp, hdrLen) != hdrLen) | 739 | if (f->readBlock(tmp, hdrLen) != hdrLen) |
740 | return e_readFile; | 740 | return e_readFile; |
741 | if (memcmp(tmp, magicHdr, hdrLen) != 0) | 741 | if (memcmp(tmp, magicHdr, hdrLen) != 0) |
742 | return e_fileFormat; | 742 | return e_fileFormat; |
743 | // read and check file ver | 743 | // read and check file ver |
744 | int fileV = f->getch(); | 744 | int fileV = f->getch(); |
745 | if (fileV == -1) | 745 | if (fileV == -1) |
746 | return e_fileFormat; | 746 | return e_fileFormat; |
747 | if (fileV != PWM_FILE_VER) | 747 | if (fileV != PWM_FILE_VER) |
748 | return e_fileVer; | 748 | return e_fileVer; |
749 | // read hash hash type | 749 | // read hash hash type |
750 | int keyHash = f->getch(); | 750 | int keyHash = f->getch(); |
751 | if (keyHash == -1) | 751 | if (keyHash == -1) |
752 | return e_fileFormat; | 752 | return e_fileFormat; |
753 | // read data hash type | 753 | // read data hash type |
754 | tmpRet = f->getch(); | 754 | tmpRet = f->getch(); |
755 | if (tmpRet == -1) | 755 | if (tmpRet == -1) |
756 | return e_fileFormat; | 756 | return e_fileFormat; |
757 | *dataHashType = tmpRet; | 757 | *dataHashType = tmpRet; |
758 | // read crypt algo | 758 | // read crypt algo |
759 | tmpRet = f->getch(); | 759 | tmpRet = f->getch(); |
760 | if (tmpRet == -1) | 760 | if (tmpRet == -1) |
761 | return e_fileFormat; | 761 | return e_fileFormat; |
762 | *cryptAlgo = tmpRet; | 762 | *cryptAlgo = tmpRet; |
763 | // get compression-algo | 763 | // get compression-algo |
764 | tmpRet = f->getch(); | 764 | tmpRet = f->getch(); |
765 | if (tmpRet == -1) | 765 | if (tmpRet == -1) |
766 | return e_fileFormat; | 766 | return e_fileFormat; |
767 | *compress = tmpRet; | 767 | *compress = tmpRet; |
768 | // get the MPW-flag | 768 | // get the MPW-flag |
769 | int mpw_flag = f->getch(); | 769 | int mpw_flag = f->getch(); |
770 | if (mpw_flag == -1) | 770 | if (mpw_flag == -1) |
771 | return e_fileFormat; | 771 | return e_fileFormat; |
772 | if (mpw_flag == 0x01) | 772 | if (mpw_flag == 0x01) |
773 | setDocStatFlag(DOC_STAT_USE_CHIPCARD); | 773 | setDocStatFlag(DOC_STAT_USE_CHIPCARD); |
774 | else | 774 | else |
775 | unsetDocStatFlag(DOC_STAT_USE_CHIPCARD); | 775 | unsetDocStatFlag(DOC_STAT_USE_CHIPCARD); |
776 | // skip the "RESERVED"-bytes | 776 | // skip the "RESERVED"-bytes |
777 | if (!(f->at(f->at() + 64))) | 777 | if (!(f->at(f->at() + 64))) |
778 | return e_fileFormat; | 778 | return e_fileFormat; |
779 | 779 | ||
780 | *pw = requestMpw(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); | 780 | *pw = requestMpw(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); |
781 | if (*pw == "") { | 781 | if (*pw == "") { |
782 | /* the user didn't give a master-password | 782 | /* the user didn't give a master-password |
783 | * or didn't insert a chipcard | 783 | * or didn't insert a chipcard |
784 | */ | 784 | */ |
785 | return e_noPw; | 785 | return e_noPw; |
786 | } | 786 | } |
787 | // verify key-hash | 787 | // verify key-hash |
788 | switch (keyHash) { | 788 | switch (keyHash) { |
789 | case PWM_HASH_SHA1: { | 789 | case PWM_HASH_SHA1: { |
790 | // read hash from header | 790 | // read hash from header |
791 | const int hashLen = SHA1_HASH_LEN_BYTE; | 791 | const int hashLen = SHA1_HASH_LEN_BYTE; |
792 | string readHash; | 792 | string readHash; |
793 | int i; | 793 | int i; |
794 | for (i = 0; i < hashLen; ++i) | 794 | for (i = 0; i < hashLen; ++i) |
795 | readHash.push_back(f->getch()); | 795 | readHash.push_back(f->getch()); |
796 | Sha1 hash; | 796 | Sha1 hash; |
797 | hash.sha1_write(reinterpret_cast<const byte *>(pw->latin1()), pw->length()); | 797 | hash.sha1_write(reinterpret_cast<const byte *>(pw->latin1()), pw->length()); |
798 | string ret = hash.sha1_read(); | 798 | string ret = hash.sha1_read(); |
799 | if (ret != readHash) | 799 | if (ret != readHash) |
800 | return e_wrongPw;// hash doesn't match (wrong key) | 800 | return e_wrongPw;// hash doesn't match (wrong key) |
801 | break; | 801 | break; |
802 | } | 802 | } |
803 | case PWM_HASH_SHA256: | 803 | case PWM_HASH_SHA256: |
804 | /*... fall through */ | 804 | /*... fall through */ |
805 | case PWM_HASH_SHA384: | 805 | case PWM_HASH_SHA384: |
806 | case PWM_HASH_SHA512: | 806 | case PWM_HASH_SHA512: |
807 | case PWM_HASH_MD5: | 807 | case PWM_HASH_MD5: |
808 | case PWM_HASH_RMD160: | 808 | case PWM_HASH_RMD160: |
809 | case PWM_HASH_TIGER: { | 809 | case PWM_HASH_TIGER: { |
810 | if (!LibGCryptIf::available()) | 810 | if (!LibGCryptIf::available()) |
811 | return e_hashNotImpl; | 811 | return e_hashNotImpl; |
812 | LibGCryptIf gc; | 812 | LibGCryptIf gc; |
813 | PwMerror err; | 813 | PwMerror err; |
814 | unsigned char *buf; | 814 | unsigned char *buf; |
815 | size_t hashLen; | 815 | size_t hashLen; |
816 | err = gc.hash(&buf, | 816 | err = gc.hash(&buf, |
817 | &hashLen, | 817 | &hashLen, |
818 | reinterpret_cast<const unsigned char *>(pw->latin1()), | 818 | reinterpret_cast<const unsigned char *>(pw->latin1()), |
819 | pw->length(), | 819 | pw->length(), |
820 | keyHash); | 820 | keyHash); |
821 | if (err != e_success) | 821 | if (err != e_success) |
822 | return e_hashNotImpl; | 822 | return e_hashNotImpl; |
823 | string calcHash(reinterpret_cast<const char *>(buf), | 823 | string calcHash(reinterpret_cast<const char *>(buf), |
824 | static_cast<string::size_type>(hashLen)); | 824 | static_cast<string::size_type>(hashLen)); |
825 | delete [] buf; | 825 | delete [] buf; |
826 | // read hash from header | 826 | // read hash from header |
827 | string readHash; | 827 | string readHash; |
828 | size_t i; | 828 | size_t i; |
829 | for (i = 0; i < hashLen; ++i) | 829 | for (i = 0; i < hashLen; ++i) |
830 | readHash.push_back(f->getch()); | 830 | readHash.push_back(f->getch()); |
831 | if (calcHash != readHash) | 831 | if (calcHash != readHash) |
832 | return e_wrongPw;// hash doesn't match (wrong key) | 832 | return e_wrongPw;// hash doesn't match (wrong key) |
833 | break; | 833 | break; |
834 | } | 834 | } |
835 | default: { | 835 | default: { |
836 | return e_hashNotImpl; | 836 | return e_hashNotImpl; |
837 | } } | 837 | } } |
838 | // read the data-hash from the file | 838 | // read the data-hash from the file |
839 | unsigned int hashLen, i; | 839 | unsigned int hashLen, i; |
840 | switch (*dataHashType) { | 840 | switch (*dataHashType) { |
841 | case PWM_HASH_SHA1: | 841 | case PWM_HASH_SHA1: |
842 | hashLen = SHA1_HASH_LEN_BYTE; | 842 | hashLen = SHA1_HASH_LEN_BYTE; |
843 | break; | 843 | break; |
844 | case PWM_HASH_SHA256: | 844 | case PWM_HASH_SHA256: |
845 | /*... fall through */ | 845 | /*... fall through */ |
846 | case PWM_HASH_SHA384: | 846 | case PWM_HASH_SHA384: |
847 | case PWM_HASH_SHA512: | 847 | case PWM_HASH_SHA512: |
848 | case PWM_HASH_MD5: | 848 | case PWM_HASH_MD5: |
849 | case PWM_HASH_RMD160: | 849 | case PWM_HASH_RMD160: |
850 | case PWM_HASH_TIGER: { | 850 | case PWM_HASH_TIGER: { |
851 | if (!LibGCryptIf::available()) | 851 | if (!LibGCryptIf::available()) |
852 | return e_hashNotImpl; | 852 | return e_hashNotImpl; |
853 | LibGCryptIf gc; | 853 | LibGCryptIf gc; |
854 | hashLen = gc.hashLength(*dataHashType); | 854 | hashLen = gc.hashLength(*dataHashType); |
855 | if (hashLen == 0) | 855 | if (hashLen == 0) |
856 | return e_hashNotImpl; | 856 | return e_hashNotImpl; |
857 | break; | 857 | break; |
858 | } | 858 | } |
859 | default: | 859 | default: |
860 | return e_hashNotImpl; | 860 | return e_hashNotImpl; |
861 | } | 861 | } |
862 | *dataHash = ""; | 862 | *dataHash = ""; |
863 | for (i = 0; i < hashLen; ++i) { | 863 | for (i = 0; i < hashLen; ++i) { |
864 | tmpRet = f->getch(); | 864 | tmpRet = f->getch(); |
865 | if (tmpRet == -1) | 865 | if (tmpRet == -1) |
866 | return e_fileFormat; | 866 | return e_fileFormat; |
867 | dataHash->push_back(static_cast<char>(tmpRet)); | 867 | dataHash->push_back(static_cast<char>(tmpRet)); |
868 | } | 868 | } |
869 | *headerLength = f->at(); | 869 | *headerLength = f->at(); |
870 | #ifndef PWM_EMBEDDED | 870 | #ifndef PWM_EMBEDDED |
871 | printDebug(string("opening file { compress: ") | 871 | printDebug(string("opening file { compress: ") |
872 | + tostr(static_cast<int>(*compress)) + " cryptAlgo: " | 872 | + tostr(static_cast<int>(*compress)) + " cryptAlgo: " |
873 | + tostr(static_cast<int>(*cryptAlgo)) + " keyHashAlgo: " | 873 | + tostr(static_cast<int>(*cryptAlgo)) + " keyHashAlgo: " |
874 | + tostr(static_cast<int>(keyHash)) | 874 | + tostr(static_cast<int>(keyHash)) |
875 | + " }"); | 875 | + " }"); |
876 | #else | 876 | #else |
877 | printDebug(string("opening file { compress: ") | 877 | printDebug(string("opening file { compress: ") |
878 | + tostr((int)(*compress)) + " cryptAlgo: " | 878 | + tostr((int)(*compress)) + " cryptAlgo: " |
879 | + tostr((int)(*cryptAlgo)) + " keyHashAlgo: " | 879 | + tostr((int)(*cryptAlgo)) + " keyHashAlgo: " |
880 | + tostr((int)(keyHash)) | 880 | + tostr((int)(keyHash)) |
881 | + " }"); | 881 | + " }"); |
882 | #endif | 882 | #endif |
883 | 883 | ||
884 | return e_success; | 884 | return e_success; |
885 | } | 885 | } |
886 | 886 | ||
887 | PwMerror PwMDoc::writeDataHash(char dataHash, string *d, QFile *f) | 887 | PwMerror PwMDoc::writeDataHash(char dataHash, string *d, QFile *f) |
888 | { | 888 | { |
889 | PWM_ASSERT(d); | 889 | PWM_ASSERT(d); |
890 | PWM_ASSERT(f); | 890 | PWM_ASSERT(f); |
891 | 891 | ||
892 | switch (dataHash) { | 892 | switch (dataHash) { |
893 | case PWM_HASH_SHA1: { | 893 | case PWM_HASH_SHA1: { |
894 | const int hashLen = SHA1_HASH_LEN_BYTE; | 894 | const int hashLen = SHA1_HASH_LEN_BYTE; |
895 | Sha1 h; | 895 | Sha1 h; |
896 | h.sha1_write(reinterpret_cast<const byte *>(d->c_str()), d->size()); | 896 | h.sha1_write(reinterpret_cast<const byte *>(d->c_str()), d->size()); |
897 | string hRet = h.sha1_read(); | 897 | string hRet = h.sha1_read(); |
898 | if (f->writeBlock(hRet.c_str(), hashLen) != hashLen) | 898 | if (f->writeBlock(hRet.c_str(), hashLen) != hashLen) |
899 | return e_writeFile; | 899 | return e_writeFile; |
900 | break; | 900 | break; |
901 | } | 901 | } |
902 | case PWM_HASH_SHA256: | 902 | case PWM_HASH_SHA256: |
903 | /*... fall through */ | 903 | /*... fall through */ |
904 | case PWM_HASH_SHA384: | 904 | case PWM_HASH_SHA384: |
905 | case PWM_HASH_SHA512: | 905 | case PWM_HASH_SHA512: |
906 | case PWM_HASH_MD5: | 906 | case PWM_HASH_MD5: |
907 | case PWM_HASH_RMD160: | 907 | case PWM_HASH_RMD160: |
908 | case PWM_HASH_TIGER: { | 908 | case PWM_HASH_TIGER: { |
909 | if (!LibGCryptIf::available()) | 909 | if (!LibGCryptIf::available()) |
910 | return e_hashNotImpl; | 910 | return e_hashNotImpl; |
911 | LibGCryptIf gc; | 911 | LibGCryptIf gc; |
912 | PwMerror err; | 912 | PwMerror err; |
913 | unsigned char *buf; | 913 | unsigned char *buf; |
914 | size_t hashLen; | 914 | size_t hashLen; |
915 | err = gc.hash(&buf, | 915 | err = gc.hash(&buf, |
916 | &hashLen, | 916 | &hashLen, |
917 | reinterpret_cast<const unsigned char *>(d->c_str()), | 917 | reinterpret_cast<const unsigned char *>(d->c_str()), |
918 | d->size(), | 918 | d->size(), |
919 | dataHash); | 919 | dataHash); |
920 | if (err != e_success) | 920 | if (err != e_success) |
921 | return e_hashNotImpl; | 921 | return e_hashNotImpl; |
922 | if (f->writeBlock(reinterpret_cast<const char *>(buf), hashLen) | 922 | if (f->writeBlock(reinterpret_cast<const char *>(buf), hashLen) |
923 | != static_cast<Q_LONG>(hashLen)) { | 923 | != static_cast<Q_LONG>(hashLen)) { |
924 | delete [] buf; | 924 | delete [] buf; |
925 | return e_hashNotImpl; | 925 | return e_hashNotImpl; |
926 | } | 926 | } |
927 | delete [] buf; | 927 | delete [] buf; |
928 | break; | 928 | break; |
929 | } | 929 | } |
930 | default: { | 930 | default: { |
931 | return e_hashNotImpl; | 931 | return e_hashNotImpl; |
932 | } } | 932 | } } |
933 | 933 | ||
934 | return e_success; | 934 | return e_success; |
935 | } | 935 | } |
936 | 936 | ||
937 | bool PwMDoc::backupFile(const QString &filePath) | 937 | bool PwMDoc::backupFile(const QString &filePath) |
938 | { | 938 | { |
939 | QFileInfo fi(filePath); | 939 | QFileInfo fi(filePath); |
940 | if (!fi.exists()) | 940 | if (!fi.exists()) |
941 | return true; // Yes, true is correct. | 941 | return true; // Yes, true is correct. |
942 | QString pathOnly(fi.dirPath(true)); | 942 | QString pathOnly(fi.dirPath(true)); |
943 | QString nameOnly(fi.fileName()); | 943 | QString nameOnly(fi.fileName()); |
944 | QString backupPath = pathOnly | 944 | QString backupPath = pathOnly |
945 | + "/~" | 945 | + "/~" |
946 | + nameOnly | 946 | + nameOnly |
947 | + ".backup"; | 947 | + ".backup"; |
948 | return copyFile(filePath, backupPath); | 948 | return copyFile(filePath, backupPath); |
949 | } | 949 | } |
950 | 950 | ||
951 | bool PwMDoc::copyFile(const QString &src, const QString &dst) | 951 | bool PwMDoc::copyFile(const QString &src, const QString &dst) |
952 | { | 952 | { |
953 | QFileInfo fi(src); | 953 | QFileInfo fi(src); |
954 | if (!fi.exists()) | 954 | if (!fi.exists()) |
955 | return false; | 955 | return false; |
956 | if (QFile::exists(dst)) { | 956 | if (QFile::exists(dst)) { |
957 | if (!QFile::remove(dst)) | 957 | if (!QFile::remove(dst)) |
958 | return false; | 958 | return false; |
959 | } | 959 | } |
960 | QFile srcFd(src); | 960 | QFile srcFd(src); |
961 | if (!srcFd.open(IO_ReadOnly)) | 961 | if (!srcFd.open(IO_ReadOnly)) |
962 | return false; | 962 | return false; |
963 | QFile dstFd(dst); | 963 | QFile dstFd(dst); |
964 | if (!dstFd.open(IO_ReadWrite)) { | 964 | if (!dstFd.open(IO_ReadWrite)) { |
965 | srcFd.close(); | 965 | srcFd.close(); |
966 | return false; | 966 | return false; |
967 | } | 967 | } |
968 | const int tmpBuf_size = 512; | 968 | const int tmpBuf_size = 512; |
969 | char tmpBuf[tmpBuf_size]; | 969 | char tmpBuf[tmpBuf_size]; |
970 | Q_LONG bytesRead, bytesWritten; | 970 | Q_LONG bytesRead, bytesWritten; |
971 | 971 | ||
972 | while (!srcFd.atEnd()) { | 972 | while (!srcFd.atEnd()) { |
973 | bytesRead = srcFd.readBlock(tmpBuf, | 973 | bytesRead = srcFd.readBlock(tmpBuf, |
974 | static_cast<Q_ULONG>(tmpBuf_size)); | 974 | static_cast<Q_ULONG>(tmpBuf_size)); |
975 | if (bytesRead == -1) { | 975 | if (bytesRead == -1) { |
976 | srcFd.close(); | 976 | srcFd.close(); |
977 | dstFd.close(); | 977 | dstFd.close(); |
978 | return false; | 978 | return false; |
979 | } | 979 | } |
980 | bytesWritten = dstFd.writeBlock(tmpBuf, | 980 | bytesWritten = dstFd.writeBlock(tmpBuf, |
981 | static_cast<Q_ULONG>(bytesRead)); | 981 | static_cast<Q_ULONG>(bytesRead)); |
982 | if (bytesWritten != bytesRead) { | 982 | if (bytesWritten != bytesRead) { |
983 | srcFd.close(); | 983 | srcFd.close(); |
984 | dstFd.close(); | 984 | dstFd.close(); |
985 | return false; | 985 | return false; |
986 | } | 986 | } |
987 | } | 987 | } |
988 | srcFd.close(); | 988 | srcFd.close(); |
989 | dstFd.close(); | 989 | dstFd.close(); |
990 | return true; | 990 | return true; |
991 | } | 991 | } |
992 | 992 | ||
993 | PwMerror PwMDoc::addEntry(const QString &category, PwMDataItem *d, | 993 | PwMerror PwMDoc::addEntry(const QString &category, PwMDataItem *d, |
994 | bool dontFlagDirty, bool updateMeta) | 994 | bool dontFlagDirty, bool updateMeta) |
995 | { | 995 | { |
996 | PWM_ASSERT(d); | 996 | PWM_ASSERT(d); |
997 | unsigned int cat = 0; | 997 | unsigned int cat = 0; |
998 | 998 | ||
999 | if (isDeepLocked()) { | 999 | if (isDeepLocked()) { |
1000 | PwMerror ret; | 1000 | PwMerror ret; |
1001 | ret = deepLock(false); | 1001 | ret = deepLock(false); |
1002 | if (ret != e_success) | 1002 | if (ret != e_success) |
1003 | return e_lock; | 1003 | return e_lock; |
1004 | } | 1004 | } |
1005 | 1005 | ||
1006 | addCategory(category, &cat); | 1006 | addCategory(category, &cat); |
1007 | 1007 | ||
1008 | if (numEntries(category) >= maxEntries) | 1008 | if (numEntries(category) >= maxEntries) |
1009 | return e_maxAllowedEntr; | 1009 | return e_maxAllowedEntr; |
1010 | 1010 | ||
1011 | vector<unsigned int> foundPositions; | 1011 | vector<unsigned int> foundPositions; |
1012 | /* historically this was: | 1012 | /* historically this was: |
1013 | *const int searchIn = SEARCH_IN_DESC | SEARCH_IN_NAME | | 1013 | *const int searchIn = SEARCH_IN_DESC | SEARCH_IN_NAME | |
1014 | * SEARCH_IN_URL | SEARCH_IN_LAUNCHER; | 1014 | * SEARCH_IN_URL | SEARCH_IN_LAUNCHER; |
1015 | * But for now we only search in desc. | 1015 | * But for now we only search in desc. |
1016 | * That's a tweak to be KWallet compatible. But it should not add | 1016 | * That's a tweak to be KWallet compatible. But it should not add |
1017 | * usability-drop onto PwManager, does it? | 1017 | * usability-drop onto PwManager, does it? |
1018 | * (And yes, "int" was a bug. Correct is "unsigned int") | 1018 | * (And yes, "int" was a bug. Correct is "unsigned int") |
1019 | */ | 1019 | */ |
1020 | const unsigned int searchIn = SEARCH_IN_DESC; | 1020 | const unsigned int searchIn = SEARCH_IN_DESC; |
1021 | findEntry(cat, *d, searchIn, &foundPositions, true); | 1021 | findEntry(cat, *d, searchIn, &foundPositions, true); |
1022 | if (foundPositions.size()) { | 1022 | if (foundPositions.size()) { |
1023 | // DOH! We found this entry. | 1023 | // DOH! We found this entry. |
1024 | return e_entryExists; | 1024 | return e_entryExists; |
1025 | } | 1025 | } |
1026 | 1026 | ||
1027 | d->listViewPos = -1; | 1027 | d->listViewPos = -1; |
1028 | d->lockStat = conf()->confGlobNewEntrLockStat(); | 1028 | d->lockStat = conf()->confGlobNewEntrLockStat(); |
1029 | if (updateMeta) { | 1029 | if (updateMeta) { |
1030 | d->meta.create = QDateTime::currentDateTime(); | 1030 | d->meta.create = QDateTime::currentDateTime(); |
1031 | d->meta.update = d->meta.create; | 1031 | d->meta.update = d->meta.create; |
1032 | } | 1032 | } |
1033 | dti.dta[cat].d.push_back(*d); | 1033 | dti.dta[cat].d.push_back(*d); |
1034 | 1034 | ||
1035 | delAllEmptyCat(true); | 1035 | delAllEmptyCat(true); |
1036 | 1036 | ||
1037 | if (!dontFlagDirty) | 1037 | if (!dontFlagDirty) |
1038 | flagDirty(); | 1038 | flagDirty(); |
1039 | return e_success; | 1039 | return e_success; |
1040 | } | 1040 | } |
1041 | 1041 | ||
1042 | PwMerror PwMDoc::addCategory(const QString &category, unsigned int *categoryIndex, | 1042 | PwMerror PwMDoc::addCategory(const QString &category, unsigned int *categoryIndex, |
1043 | bool checkIfExist) | 1043 | bool checkIfExist) |
1044 | { | 1044 | { |
1045 | if (isDeepLocked()) { | 1045 | if (isDeepLocked()) { |
1046 | PwMerror ret; | 1046 | PwMerror ret; |
1047 | ret = deepLock(false); | 1047 | ret = deepLock(false); |
1048 | if (ret != e_success) | 1048 | if (ret != e_success) |
1049 | return e_lock; | 1049 | return e_lock; |
1050 | } | 1050 | } |
1051 | if (checkIfExist) { | 1051 | if (checkIfExist) { |
1052 | if (findCategory(category, categoryIndex)) | 1052 | if (findCategory(category, categoryIndex)) |
1053 | return e_categoryExists; | 1053 | return e_categoryExists; |
1054 | } | 1054 | } |
1055 | PwMCategoryItem item; | 1055 | PwMCategoryItem item; |
1056 | //US ENH: clear item to initialize with default values, or create a constructor | 1056 | //US ENH: clear item to initialize with default values, or create a constructor |
1057 | item.clear(); | 1057 | item.clear(); |
1058 | 1058 | ||
1059 | item.name = category.latin1(); | 1059 | item.name = category.latin1(); |
1060 | dti.dta.push_back(item); | 1060 | dti.dta.push_back(item); |
1061 | if (categoryIndex) | 1061 | if (categoryIndex) |
1062 | *categoryIndex = dti.dta.size() - 1; | 1062 | *categoryIndex = dti.dta.size() - 1; |
1063 | return e_success; | 1063 | return e_success; |
1064 | } | 1064 | } |
1065 | 1065 | ||
1066 | bool PwMDoc::delEntry(const QString &category, unsigned int index, bool dontFlagDirty) | 1066 | bool PwMDoc::delEntry(const QString &category, unsigned int index, bool dontFlagDirty) |
1067 | { | 1067 | { |
1068 | unsigned int cat = 0; | 1068 | unsigned int cat = 0; |
1069 | 1069 | ||
1070 | if (!findCategory(category, &cat)) { | 1070 | if (!findCategory(category, &cat)) { |
1071 | BUG(); | 1071 | BUG(); |
1072 | return false; | 1072 | return false; |
1073 | } | 1073 | } |
1074 | 1074 | ||
1075 | return delEntry(cat, index, dontFlagDirty); | 1075 | return delEntry(cat, index, dontFlagDirty); |
1076 | } | 1076 | } |
1077 | 1077 | ||
1078 | bool PwMDoc::delEntry(unsigned int category, unsigned int index, bool dontFlagDirty) | 1078 | bool PwMDoc::delEntry(unsigned int category, unsigned int index, bool dontFlagDirty) |
1079 | { | 1079 | { |
1080 | if (isDeepLocked()) | 1080 | if (isDeepLocked()) |
1081 | return false; | 1081 | return false; |
1082 | if (index > dti.dta[category].d.size() - 1) | 1082 | if (index > dti.dta[category].d.size() - 1) |
1083 | return false; | 1083 | return false; |
1084 | getDataChangedLock(); | 1084 | getDataChangedLock(); |
1085 | if (!lockAt(category, index, false)) { | 1085 | if (!lockAt(category, index, false)) { |
1086 | putDataChangedLock(); | 1086 | putDataChangedLock(); |
1087 | return false; | 1087 | return false; |
1088 | } | 1088 | } |
1089 | putDataChangedLock(); | 1089 | putDataChangedLock(); |
1090 | int lvPos = dti.dta[category].d[index].listViewPos; | 1090 | int lvPos = dti.dta[category].d[index].listViewPos; |
1091 | 1091 | ||
1092 | // delete entry | 1092 | // delete entry |
1093 | dti.dta[category].d.erase(dti.dta[category].d.begin() + index); | 1093 | dti.dta[category].d.erase(dti.dta[category].d.begin() + index); |
1094 | 1094 | ||
1095 | unsigned int i, entries = numEntries(category); | 1095 | unsigned int i, entries = numEntries(category); |
1096 | if (!entries) { | 1096 | if (!entries) { |
1097 | // no more entries in this category, so | 1097 | // no more entries in this category, so |
1098 | // we can delete it, too. | 1098 | // we can delete it, too. |
1099 | BUG_ON(!delCategory(category)); | 1099 | BUG_ON(!delCategory(category)); |
1100 | // delCategory() flags it dirty, so we need not to do so. | 1100 | // delCategory() flags it dirty, so we need not to do so. |
1101 | return true; | 1101 | return true; |
1102 | } | 1102 | } |
1103 | for (i = 0; i < entries; ++i) { | 1103 | for (i = 0; i < entries; ++i) { |
1104 | // decrement all listViewPositions that are greater than the deleted. | 1104 | // decrement all listViewPositions that are greater than the deleted. |
1105 | if (dti.dta[category].d[i].listViewPos > lvPos) | 1105 | if (dti.dta[category].d[i].listViewPos > lvPos) |
1106 | --dti.dta[category].d[i].listViewPos; | 1106 | --dti.dta[category].d[i].listViewPos; |
1107 | } | 1107 | } |
1108 | 1108 | ||
1109 | if (!dontFlagDirty) | 1109 | if (!dontFlagDirty) |
1110 | flagDirty(); | 1110 | flagDirty(); |
1111 | return true; | 1111 | return true; |
1112 | } | 1112 | } |
1113 | 1113 | ||
1114 | bool PwMDoc::editEntry(const QString &oldCategory, const QString &newCategory, | 1114 | bool PwMDoc::editEntry(const QString &oldCategory, const QString &newCategory, |
1115 | unsigned int index, PwMDataItem *d, bool updateMeta) | 1115 | unsigned int index, PwMDataItem *d, bool updateMeta) |
1116 | { | 1116 | { |
1117 | PWM_ASSERT(d); | 1117 | PWM_ASSERT(d); |
1118 | unsigned int oldCat = 0; | 1118 | unsigned int oldCat = 0; |
1119 | 1119 | ||
1120 | if (!findCategory(oldCategory, &oldCat)) { | 1120 | if (!findCategory(oldCategory, &oldCat)) { |
1121 | BUG(); | 1121 | BUG(); |
1122 | return false; | 1122 | return false; |
1123 | } | 1123 | } |
1124 | 1124 | ||
1125 | return editEntry(oldCat, newCategory, index, d, updateMeta); | 1125 | return editEntry(oldCat, newCategory, index, d, updateMeta); |
1126 | } | 1126 | } |
1127 | 1127 | ||
1128 | bool PwMDoc::editEntry(unsigned int oldCategory, const QString &newCategory, | 1128 | bool PwMDoc::editEntry(unsigned int oldCategory, const QString &newCategory, |
1129 | unsigned int index, PwMDataItem *d, bool updateMeta) | 1129 | unsigned int index, PwMDataItem *d, bool updateMeta) |
1130 | { | 1130 | { |
1131 | if (isDeepLocked()) | 1131 | if (isDeepLocked()) |
1132 | return false; | 1132 | return false; |
1133 | if (updateMeta) { | 1133 | if (updateMeta) { |
1134 | d->meta.update = QDateTime::currentDateTime(); | 1134 | d->meta.update = QDateTime::currentDateTime(); |
1135 | if (d->meta.create.isNull()) { | 1135 | if (d->meta.create.isNull()) { |
1136 | d->meta.create = d->meta.update; | 1136 | d->meta.create = d->meta.update; |
1137 | } | 1137 | } |
1138 | } | 1138 | } |
1139 | if (dti.dta[oldCategory].name != newCategory.latin1()) { | 1139 | if (dti.dta[oldCategory].name != newCategory.latin1()) { |
1140 | // the user changed the category. | 1140 | // the user changed the category. |
1141 | PwMerror ret; | 1141 | PwMerror ret; |
1142 | d->rev = 0; | 1142 | d->rev = 0; |
1143 | ret = addEntry(newCategory, d, true, false); | 1143 | ret = addEntry(newCategory, d, true, false); |
1144 | if (ret != e_success) | 1144 | if (ret != e_success) |
1145 | return false; | 1145 | return false; |
1146 | if (!delEntry(oldCategory, index, true)) | 1146 | if (!delEntry(oldCategory, index, true)) |
1147 | return false; | 1147 | return false; |
1148 | } else { | 1148 | } else { |
1149 | d->rev = dti.dta[oldCategory].d[index].rev + 1; // increment revision counter. | 1149 | d->rev = dti.dta[oldCategory].d[index].rev + 1; // increment revision counter. |
1150 | dti.dta[oldCategory].d[index] = *d; | 1150 | dti.dta[oldCategory].d[index] = *d; |
1151 | } | 1151 | } |
1152 | flagDirty(); | 1152 | flagDirty(); |
1153 | return true; | 1153 | return true; |
1154 | } | 1154 | } |
1155 | 1155 | ||
1156 | unsigned int PwMDoc::numEntries(const QString &category) | 1156 | unsigned int PwMDoc::numEntries(const QString &category) |
1157 | { | 1157 | { |
1158 | unsigned int cat = 0; | 1158 | unsigned int cat = 0; |
1159 | 1159 | ||
1160 | if (!findCategory(category, &cat)) { | 1160 | if (!findCategory(category, &cat)) { |
1161 | BUG(); | 1161 | BUG(); |
1162 | return 0; | 1162 | return 0; |
1163 | } | 1163 | } |
1164 | 1164 | ||
1165 | return numEntries(cat); | 1165 | return numEntries(cat); |
1166 | } | 1166 | } |
1167 | 1167 | ||
1168 | bool PwMDoc::serializeDta(string *d) | 1168 | bool PwMDoc::serializeDta(string *d) |
1169 | { | 1169 | { |
1170 | PWM_ASSERT(d); | 1170 | PWM_ASSERT(d); |
1171 | Serializer ser; | 1171 | Serializer ser; |
1172 | if (!ser.serialize(dti)) | 1172 | if (!ser.serialize(dti)) |
1173 | return false; | 1173 | return false; |
1174 | d->assign(ser.getXml()); | 1174 | d->assign(ser.getXml()); |
1175 | if (!d->size()) | 1175 | if (!d->size()) |
1176 | return false; | 1176 | return false; |
1177 | return true; | 1177 | return true; |
1178 | } | 1178 | } |
1179 | 1179 | ||
1180 | bool PwMDoc::deSerializeDta(const string *d, bool entriesLocked) | 1180 | bool PwMDoc::deSerializeDta(const string *d, bool entriesLocked) |
1181 | { | 1181 | { |
1182 | PWM_ASSERT(d); | 1182 | PWM_ASSERT(d); |
1183 | #ifndef PWM_EMBEDDED | 1183 | #ifndef PWM_EMBEDDED |
1184 | try { | 1184 | try { |
1185 | 1185 | ||
1186 | Serializer ser(d->c_str()); | 1186 | Serializer ser(d->c_str()); |
1187 | ser.setDefaultLockStat(entriesLocked); | 1187 | ser.setDefaultLockStat(entriesLocked); |
1188 | if (!ser.deSerialize(&dti)) | 1188 | if (!ser.deSerialize(&dti)) |
1189 | return false; | 1189 | return false; |
1190 | } catch (PwMException) { | 1190 | } catch (PwMException) { |
1191 | return false; | 1191 | return false; |
1192 | } | 1192 | } |
1193 | #else | 1193 | #else |
1194 | Serializer ser(d->c_str()); | 1194 | Serializer ser(d->c_str()); |
1195 | ser.setDefaultLockStat(entriesLocked); | 1195 | ser.setDefaultLockStat(entriesLocked); |
1196 | if (!ser.deSerialize(&dti)) | 1196 | if (!ser.deSerialize(&dti)) |
1197 | return false; | 1197 | return false; |
1198 | #endif | 1198 | #endif |
1199 | 1199 | ||
1200 | emitDataChanged(this); | 1200 | emitDataChanged(this); |
1201 | return true; | 1201 | return true; |
1202 | } | 1202 | } |
1203 | 1203 | ||
1204 | bool PwMDoc::getEntry(const QString &category, unsigned int index, | 1204 | bool PwMDoc::getEntry(const QString &category, unsigned int index, |
1205 | PwMDataItem * d, bool unlockIfLocked) | 1205 | PwMDataItem * d, bool unlockIfLocked) |
1206 | { | 1206 | { |
1207 | PWM_ASSERT(d); | 1207 | PWM_ASSERT(d); |
1208 | unsigned int cat = 0; | 1208 | unsigned int cat = 0; |
1209 | 1209 | ||
1210 | if (!findCategory(category, &cat)) { | 1210 | if (!findCategory(category, &cat)) { |
1211 | BUG(); | 1211 | BUG(); |
1212 | return false; | 1212 | return false; |
1213 | } | 1213 | } |
1214 | 1214 | ||
1215 | return getEntry(cat, index, d, unlockIfLocked); | 1215 | return getEntry(cat, index, d, unlockIfLocked); |
1216 | } | 1216 | } |
1217 | 1217 | ||
1218 | bool PwMDoc::getEntry(unsigned int category, unsigned int index, | 1218 | bool PwMDoc::getEntry(unsigned int category, unsigned int index, |
1219 | PwMDataItem *d, bool unlockIfLocked) | 1219 | PwMDataItem *d, bool unlockIfLocked) |
1220 | { | 1220 | { |
1221 | if (index > dti.dta[category].d.size() - 1) | 1221 | if (index > dti.dta[category].d.size() - 1) |
1222 | return false; | 1222 | return false; |
1223 | 1223 | ||
1224 | bool locked = isLocked(category, index); | 1224 | bool locked = isLocked(category, index); |
1225 | if (locked) { | 1225 | if (locked) { |
1226 | /* this entry is locked. We don't return a password, | 1226 | /* this entry is locked. We don't return a password, |
1227 | * until it's unlocked by the user by inserting | 1227 | * until it's unlocked by the user by inserting |
1228 | * chipcard or entering the mpw | 1228 | * chipcard or entering the mpw |
1229 | */ | 1229 | */ |
1230 | if (unlockIfLocked) { | 1230 | if (unlockIfLocked) { |
1231 | if (!lockAt(category, index, false)) { | 1231 | if (!lockAt(category, index, false)) { |
1232 | return false; | 1232 | return false; |
1233 | } | 1233 | } |
1234 | locked = false; | 1234 | locked = false; |
1235 | } | 1235 | } |
1236 | } | 1236 | } |
1237 | 1237 | ||
1238 | *d = dti.dta[category].d[index]; | 1238 | *d = dti.dta[category].d[index]; |
1239 | if (locked) | 1239 | if (locked) |
1240 | d->pw = LOCKED_STRING.latin1(); | 1240 | d->pw = LOCKED_STRING.latin1(); |
1241 | 1241 | ||
1242 | return true; | 1242 | return true; |
1243 | } | 1243 | } |
1244 | PwMerror PwMDoc::getCommentByLvp(const QString &category, int listViewPos, | 1244 | PwMerror PwMDoc::getCommentByLvp(const QString &category, int listViewPos, |
1245 | string *foundComment) | 1245 | string *foundComment) |
1246 | { | 1246 | { |
1247 | PWM_ASSERT(foundComment); | 1247 | PWM_ASSERT(foundComment); |
1248 | unsigned int cat = 0; | 1248 | unsigned int cat = 0; |
1249 | 1249 | ||
1250 | if (!findCategory(category, &cat)) | 1250 | if (!findCategory(category, &cat)) |
1251 | return e_invalidArg; | 1251 | return e_invalidArg; |
1252 | 1252 | ||
1253 | unsigned int i, entries = numEntries(cat); | 1253 | unsigned int i, entries = numEntries(cat); |
1254 | for (i = 0; i < entries; ++i) { | 1254 | for (i = 0; i < entries; ++i) { |
1255 | if (dti.dta[cat].d[i].listViewPos == listViewPos) { | 1255 | if (dti.dta[cat].d[i].listViewPos == listViewPos) { |
1256 | *foundComment = dti.dta[cat].d[i].comment; | 1256 | *foundComment = dti.dta[cat].d[i].comment; |
1257 | if (dti.dta[cat].d[i].binary) | 1257 | if (dti.dta[cat].d[i].binary) |
1258 | return e_binEntry; | 1258 | return e_binEntry; |
1259 | return e_normalEntry; | 1259 | return e_normalEntry; |
1260 | } | 1260 | } |
1261 | } | 1261 | } |
1262 | BUG(); | 1262 | BUG(); |
1263 | return e_generic; | 1263 | return e_generic; |
1264 | } | 1264 | } |
1265 | 1265 | ||
1266 | PwMerror PwMDoc::getCommentByLvp_long(const QString &category, int listViewPos, | 1266 | PwMerror PwMDoc::getCommentByLvp_long(const QString &category, int listViewPos, |
1267 | string *foundComment) | 1267 | string *foundComment) |
1268 | { | 1268 | { |
1269 | PWM_ASSERT(foundComment); | 1269 | PWM_ASSERT(foundComment); |
1270 | unsigned int cat = 0; | 1270 | unsigned int cat = 0; |
1271 | 1271 | ||
1272 | if (!findCategory(category, &cat)) | 1272 | if (!findCategory(category, &cat)) |
1273 | return e_invalidArg; | 1273 | return e_invalidArg; |
1274 | 1274 | ||
1275 | unsigned int i, entries = numEntries(cat); | 1275 | unsigned int i, entries = numEntries(cat); |
1276 | for (i = 0; i < entries; ++i) { | 1276 | for (i = 0; i < entries; ++i) { |
1277 | if (dti.dta[cat].d[i].listViewPos == listViewPos) { | 1277 | if (dti.dta[cat].d[i].listViewPos == listViewPos) { |
1278 | if (dti.dta[cat].d[i].binary) | 1278 | if (dti.dta[cat].d[i].binary) |
1279 | return e_binEntry; | 1279 | return e_binEntry; |
1280 | PwMCategoryItem* catItem = getCategoryEntry(cat); | 1280 | PwMCategoryItem* catItem = getCategoryEntry(cat); |
1281 | QString retval; | 1281 | QString retval; |
1282 | QString tempval = QString (dti.dta[cat].d[i].desc.c_str()); | 1282 | QString tempval = QString (dti.dta[cat].d[i].desc.c_str()); |
1283 | if ( !tempval.isEmpty() ) { | 1283 | if ( !tempval.isEmpty() ) { |
1284 | retval += "<b>" +QString ( catItem->desc_text.c_str() )+ ":</b> "+ tempval+"<br>" ; | 1284 | retval += "<b>" +QString ( catItem->desc_text.c_str() )+ ":</b> "+ tempval+"<br>" ; |
1285 | } | 1285 | } |
1286 | tempval = QString (dti.dta[cat].d[i].name.c_str()); | 1286 | tempval = QString (dti.dta[cat].d[i].name.c_str()); |
1287 | if ( !tempval.isEmpty() ) { | 1287 | if ( !tempval.isEmpty() ) { |
1288 | retval += "<b>" +QString ( catItem->name_text.c_str() ) + ":</b> "+ tempval+"<br>" ; | 1288 | retval += "<b>" +QString ( catItem->name_text.c_str() ) + ":</b> "+ tempval+"<br>" ; |
1289 | } | 1289 | } |
1290 | tempval = QString (dti.dta[cat].d[i].pw.c_str()); | 1290 | tempval = QString (dti.dta[cat].d[i].pw.c_str()); |
1291 | if ( !tempval.isEmpty() ) { | 1291 | if ( !tempval.isEmpty() ) { |
1292 | if ( dti.dta[cat].d[i].lockStat ) | 1292 | if ( dti.dta[cat].d[i].lockStat ) |
1293 | retval += "<b>" +QString ( catItem->pw_text.c_str() )+ ":</b> " + i18n("<LOCKED>") +"<br>" ; | 1293 | retval += "<b>" +QString ( catItem->pw_text.c_str() )+ ": " + i18n("LOCKED") +"</b><br>" ; |
1294 | else | 1294 | else |
1295 | retval += "<b>" +QString ( catItem->pw_text.c_str() )+ ":</b> " + tempval+"<br>" ; | 1295 | retval += "<b>" +QString ( catItem->pw_text.c_str() )+ ":</b> " + tempval+"<br>" ; |
1296 | } | 1296 | } |
1297 | tempval = QString (dti.dta[cat].d[i].url.c_str()); | 1297 | tempval = QString (dti.dta[cat].d[i].url.c_str()); |
1298 | if ( !tempval.isEmpty() ) { | 1298 | if ( !tempval.isEmpty() ) { |
1299 | retval += "<b>" +i18n("URL:")+ "</b> " + tempval+"<br>" ; | 1299 | retval += "<b>" +i18n("URL:")+ "</b> " + tempval+"<br>" ; |
1300 | } | 1300 | } |
1301 | tempval = QString (dti.dta[cat].d[i].launcher.c_str()); | 1301 | tempval = QString (dti.dta[cat].d[i].launcher.c_str()); |
1302 | if ( !tempval.isEmpty() ) { | 1302 | if ( !tempval.isEmpty() ) { |
1303 | retval += "<b>" +i18n("Launcher:")+ "</b> " + tempval+"<br>" ; | 1303 | retval += "<b>" +i18n("Launcher:")+ "</b> " + tempval+"<br>" ; |
1304 | } | 1304 | } |
1305 | tempval = QString (dti.dta[cat].d[i].comment.c_str()); | 1305 | tempval = QString (dti.dta[cat].d[i].comment.c_str()); |
1306 | if ( !tempval.isEmpty() ) { | 1306 | if ( !tempval.isEmpty() ) { |
1307 | tempval.replace(QRegExp ( "\n" ), "<br>" ); | 1307 | tempval.replace(QRegExp ( "\n" ), "<br>" ); |
1308 | retval += "<b>" +i18n("Comment:")+ "</b><br>" + tempval+"<br>" ; | 1308 | retval += "<b>" +i18n("Comment:")+ "</b><br>" + tempval+"<br>" ; |
1309 | } | 1309 | } |
1310 | 1310 | ||
1311 | string ret ( retval.latin1() ); | 1311 | string ret ( retval.latin1() ); |
1312 | 1312 | ||
1313 | 1313 | ||
1314 | // *foundComment = dti.dta[cat].d[i].comment; | 1314 | // *foundComment = dti.dta[cat].d[i].comment; |
1315 | *foundComment = ret; | 1315 | *foundComment = ret; |
1316 | return e_normalEntry; | 1316 | return e_normalEntry; |
1317 | } | 1317 | } |
1318 | } | 1318 | } |
1319 | BUG(); | 1319 | BUG(); |
1320 | return e_generic; | 1320 | return e_generic; |
1321 | } | 1321 | } |
1322 | 1322 | ||
1323 | bool PwMDoc::compressDta(string *d, char algo) | 1323 | bool PwMDoc::compressDta(string *d, char algo) |
1324 | { | 1324 | { |
1325 | PWM_ASSERT(d); | 1325 | PWM_ASSERT(d); |
1326 | switch (algo) { | 1326 | switch (algo) { |
1327 | case PWM_COMPRESS_GZIP: { | 1327 | case PWM_COMPRESS_GZIP: { |
1328 | CompressGzip comp; | 1328 | CompressGzip comp; |
1329 | return comp.compress(d); | 1329 | return comp.compress(d); |
1330 | } | 1330 | } |
1331 | #ifndef PWM_EMBEDDED | 1331 | #ifndef PWM_EMBEDDED |
1332 | case PWM_COMPRESS_BZIP2: { | 1332 | case PWM_COMPRESS_BZIP2: { |
1333 | CompressBzip2 comp; | 1333 | CompressBzip2 comp; |
1334 | return comp.compress(d); | 1334 | return comp.compress(d); |
1335 | } | 1335 | } |
1336 | #endif | 1336 | #endif |
1337 | case PWM_COMPRESS_NONE: { | 1337 | case PWM_COMPRESS_NONE: { |
1338 | return true; | 1338 | return true; |
1339 | } default: { | 1339 | } default: { |
1340 | BUG(); | 1340 | BUG(); |
1341 | } | 1341 | } |
1342 | } | 1342 | } |
1343 | return false; | 1343 | return false; |
1344 | } | 1344 | } |
1345 | 1345 | ||
1346 | bool PwMDoc::decompressDta(string *d, char algo) | 1346 | bool PwMDoc::decompressDta(string *d, char algo) |
1347 | { | 1347 | { |
1348 | PWM_ASSERT(d); | 1348 | PWM_ASSERT(d); |
1349 | switch (algo) { | 1349 | switch (algo) { |
1350 | case PWM_COMPRESS_GZIP: { | 1350 | case PWM_COMPRESS_GZIP: { |
1351 | CompressGzip comp; | 1351 | CompressGzip comp; |
1352 | return comp.decompress(d); | 1352 | return comp.decompress(d); |
1353 | } | 1353 | } |
1354 | #ifndef PWM_EMBEDDED | 1354 | #ifndef PWM_EMBEDDED |
1355 | case PWM_COMPRESS_BZIP2: { | 1355 | case PWM_COMPRESS_BZIP2: { |
1356 | CompressBzip2 comp; | 1356 | CompressBzip2 comp; |
1357 | return comp.decompress(d); | 1357 | return comp.decompress(d); |
1358 | } | 1358 | } |
1359 | #endif | 1359 | #endif |
1360 | case PWM_COMPRESS_NONE: { | 1360 | case PWM_COMPRESS_NONE: { |
1361 | return true; | 1361 | return true; |
1362 | } | 1362 | } |
1363 | } | 1363 | } |
1364 | return false; | 1364 | return false; |
1365 | } | 1365 | } |
1366 | 1366 | ||
1367 | PwMerror PwMDoc::encrypt(string *d, const QString *pw, QFile *f, char algo, | 1367 | PwMerror PwMDoc::encrypt(string *d, const QString *pw, QFile *f, char algo, |
1368 | char hashalgo //US BUG: pass _hashalgo because we need it in hashPassphrase | 1368 | char hashalgo //US BUG: pass _hashalgo because we need it in hashPassphrase |
1369 | ) | 1369 | ) |
1370 | { | 1370 | { |
1371 | PWM_ASSERT(d); | 1371 | PWM_ASSERT(d); |
1372 | PWM_ASSERT(pw); | 1372 | PWM_ASSERT(pw); |
1373 | PWM_ASSERT(f); | 1373 | PWM_ASSERT(f); |
1374 | 1374 | ||
1375 | size_t encSize; | 1375 | size_t encSize; |
1376 | byte *encrypted = 0; | 1376 | byte *encrypted = 0; |
1377 | 1377 | ||
1378 | switch (algo) { | 1378 | switch (algo) { |
1379 | case PWM_CRYPT_BLOWFISH: { | 1379 | case PWM_CRYPT_BLOWFISH: { |
1380 | Blowfish::padNull(d); | 1380 | Blowfish::padNull(d); |
1381 | encSize = d->length(); | 1381 | encSize = d->length(); |
1382 | encrypted = new byte[encSize]; | 1382 | encrypted = new byte[encSize]; |
1383 | Blowfish bf; | 1383 | Blowfish bf; |
1384 | if (bf.bf_setkey((byte *) pw->latin1(), pw->length())) { | 1384 | if (bf.bf_setkey((byte *) pw->latin1(), pw->length())) { |
1385 | delete [] encrypted; | 1385 | delete [] encrypted; |
1386 | return e_weakPw; | 1386 | return e_weakPw; |
1387 | } | 1387 | } |
1388 | bf.bf_encrypt((byte *) encrypted, (byte *) d->c_str(), encSize); | 1388 | bf.bf_encrypt((byte *) encrypted, (byte *) d->c_str(), encSize); |
1389 | break; | 1389 | break; |
1390 | } | 1390 | } |
1391 | case PWM_CRYPT_AES128: | 1391 | case PWM_CRYPT_AES128: |
1392 | /*... fall through */ | 1392 | /*... fall through */ |
1393 | case PWM_CRYPT_AES192: | 1393 | case PWM_CRYPT_AES192: |
1394 | case PWM_CRYPT_AES256: | 1394 | case PWM_CRYPT_AES256: |
1395 | case PWM_CRYPT_3DES: | 1395 | case PWM_CRYPT_3DES: |
1396 | case PWM_CRYPT_TWOFISH: | 1396 | case PWM_CRYPT_TWOFISH: |
1397 | case PWM_CRYPT_TWOFISH128: { | 1397 | case PWM_CRYPT_TWOFISH128: { |
1398 | if (!LibGCryptIf::available()) | 1398 | if (!LibGCryptIf::available()) |
1399 | return e_cryptNotImpl; | 1399 | return e_cryptNotImpl; |
1400 | LibGCryptIf gc; | 1400 | LibGCryptIf gc; |
1401 | PwMerror err; | 1401 | PwMerror err; |
1402 | unsigned char *plain = new unsigned char[d->length() + 1024]; | 1402 | unsigned char *plain = new unsigned char[d->length() + 1024]; |
1403 | memcpy(plain, d->c_str(), d->length()); | 1403 | memcpy(plain, d->c_str(), d->length()); |
1404 | err = gc.encrypt(&encrypted, | 1404 | err = gc.encrypt(&encrypted, |
1405 | &encSize, | 1405 | &encSize, |
1406 | plain, | 1406 | plain, |
1407 | d->length(), | 1407 | d->length(), |
1408 | reinterpret_cast<const unsigned char *>(pw->latin1()), | 1408 | reinterpret_cast<const unsigned char *>(pw->latin1()), |
1409 | pw->length(), | 1409 | pw->length(), |
1410 | algo, | 1410 | algo, |
1411 | hashalgo //US BUG: pass _hashalgo because we need it in hashPassphrase | 1411 | hashalgo //US BUG: pass _hashalgo because we need it in hashPassphrase |
1412 | ); | 1412 | ); |
1413 | delete [] plain; | 1413 | delete [] plain; |
1414 | if (err != e_success) | 1414 | if (err != e_success) |
1415 | return e_cryptNotImpl; | 1415 | return e_cryptNotImpl; |
1416 | break; | 1416 | break; |
1417 | } | 1417 | } |
1418 | default: { | 1418 | default: { |
1419 | delete_ifnot_null_array(encrypted); | 1419 | delete_ifnot_null_array(encrypted); |
1420 | return e_cryptNotImpl; | 1420 | return e_cryptNotImpl; |
1421 | } } | 1421 | } } |
1422 | 1422 | ||
1423 | // write encrypted data to file | 1423 | // write encrypted data to file |
1424 | if (f->writeBlock(reinterpret_cast<const char *>(encrypted), | 1424 | if (f->writeBlock(reinterpret_cast<const char *>(encrypted), |
1425 | static_cast<Q_ULONG>(encSize)) | 1425 | static_cast<Q_ULONG>(encSize)) |
1426 | != static_cast<Q_LONG>(encSize)) { | 1426 | != static_cast<Q_LONG>(encSize)) { |
1427 | delete_ifnot_null_array(encrypted); | 1427 | delete_ifnot_null_array(encrypted); |
1428 | return e_writeFile; | 1428 | return e_writeFile; |
1429 | } | 1429 | } |
1430 | delete_ifnot_null_array(encrypted); | 1430 | delete_ifnot_null_array(encrypted); |
1431 | return e_success; | 1431 | return e_success; |
1432 | } | 1432 | } |
1433 | 1433 | ||
1434 | PwMerror PwMDoc::decrypt(string *d, unsigned int pos, const QString *pw, | 1434 | PwMerror PwMDoc::decrypt(string *d, unsigned int pos, const QString *pw, |
1435 | char algo, | 1435 | char algo, |
1436 | char hashalgo, //US BUG: pass _hashalgo because we need it in hashPassphrase | 1436 | char hashalgo, //US BUG: pass _hashalgo because we need it in hashPassphrase |
1437 | QFile *f) | 1437 | QFile *f) |
1438 | { | 1438 | { |
1439 | PWM_ASSERT(d); | 1439 | PWM_ASSERT(d); |
1440 | PWM_ASSERT(pw); | 1440 | PWM_ASSERT(pw); |
1441 | PWM_ASSERT(f); | 1441 | PWM_ASSERT(f); |
1442 | 1442 | ||
1443 | unsigned int cryptLen = f->size() - pos; | 1443 | unsigned int cryptLen = f->size() - pos; |
1444 | byte *encrypted = new byte[cryptLen]; | 1444 | byte *encrypted = new byte[cryptLen]; |
1445 | byte *decrypted = new byte[cryptLen]; | 1445 | byte *decrypted = new byte[cryptLen]; |
1446 | 1446 | ||
1447 | f->at(pos); | 1447 | f->at(pos); |
1448 | #ifndef PWM_EMBEDDED | 1448 | #ifndef PWM_EMBEDDED |
1449 | if (f->readBlock(reinterpret_cast<char *>(encrypted), | 1449 | if (f->readBlock(reinterpret_cast<char *>(encrypted), |
1450 | static_cast<Q_ULONG>(cryptLen)) | 1450 | static_cast<Q_ULONG>(cryptLen)) |
1451 | != static_cast<Q_LONG>(cryptLen)) { | 1451 | != static_cast<Q_LONG>(cryptLen)) { |
1452 | delete [] encrypted; | 1452 | delete [] encrypted; |
1453 | delete [] decrypted; | 1453 | delete [] decrypted; |
1454 | return e_readFile; | 1454 | return e_readFile; |
1455 | } | 1455 | } |
1456 | #else | 1456 | #else |
1457 | if (f->readBlock((char *)(encrypted), | 1457 | if (f->readBlock((char *)(encrypted), |
1458 | (unsigned long)(cryptLen)) | 1458 | (unsigned long)(cryptLen)) |
1459 | != (long)(cryptLen)) { | 1459 | != (long)(cryptLen)) { |
1460 | delete [] encrypted; | 1460 | delete [] encrypted; |
1461 | delete [] decrypted; | 1461 | delete [] decrypted; |
1462 | return e_readFile; | 1462 | return e_readFile; |
1463 | } | 1463 | } |
1464 | #endif | 1464 | #endif |
1465 | switch (algo) { | 1465 | switch (algo) { |
1466 | case PWM_CRYPT_BLOWFISH: { | 1466 | case PWM_CRYPT_BLOWFISH: { |
1467 | Blowfish bf; | 1467 | Blowfish bf; |
1468 | bf.bf_setkey((byte *) pw->latin1(), pw->length()); | 1468 | bf.bf_setkey((byte *) pw->latin1(), pw->length()); |
1469 | bf.bf_decrypt(decrypted, encrypted, cryptLen); | 1469 | bf.bf_decrypt(decrypted, encrypted, cryptLen); |
1470 | break; | 1470 | break; |
1471 | } | 1471 | } |
1472 | case PWM_CRYPT_AES128: | 1472 | case PWM_CRYPT_AES128: |
1473 | /*... fall through */ | 1473 | /*... fall through */ |
1474 | case PWM_CRYPT_AES192: | 1474 | case PWM_CRYPT_AES192: |
1475 | case PWM_CRYPT_AES256: | 1475 | case PWM_CRYPT_AES256: |
1476 | case PWM_CRYPT_3DES: | 1476 | case PWM_CRYPT_3DES: |
1477 | case PWM_CRYPT_TWOFISH: | 1477 | case PWM_CRYPT_TWOFISH: |
1478 | case PWM_CRYPT_TWOFISH128: { | 1478 | case PWM_CRYPT_TWOFISH128: { |
1479 | if (!LibGCryptIf::available()) | 1479 | if (!LibGCryptIf::available()) |
1480 | return e_cryptNotImpl; | 1480 | return e_cryptNotImpl; |
1481 | LibGCryptIf gc; | 1481 | LibGCryptIf gc; |
1482 | PwMerror err; | 1482 | PwMerror err; |
1483 | err = gc.decrypt(&decrypted, | 1483 | err = gc.decrypt(&decrypted, |
1484 | &cryptLen, | 1484 | &cryptLen, |
1485 | encrypted, | 1485 | encrypted, |
1486 | cryptLen, | 1486 | cryptLen, |
1487 | reinterpret_cast<const unsigned char *>(pw->latin1()), | 1487 | reinterpret_cast<const unsigned char *>(pw->latin1()), |
1488 | pw->length(), | 1488 | pw->length(), |
1489 | algo, | 1489 | algo, |
1490 | hashalgo //US BUG: pass _hashalgo because we need it in hashPassphrase | 1490 | hashalgo //US BUG: pass _hashalgo because we need it in hashPassphrase |
1491 | ); | 1491 | ); |
1492 | if (err != e_success) { | 1492 | if (err != e_success) { |
1493 | delete [] encrypted; | 1493 | delete [] encrypted; |
1494 | delete [] decrypted; | 1494 | delete [] decrypted; |
1495 | return e_cryptNotImpl; | 1495 | return e_cryptNotImpl; |
1496 | } | 1496 | } |
1497 | break; | 1497 | break; |
1498 | } | 1498 | } |
1499 | default: { | 1499 | default: { |
1500 | delete [] encrypted; | 1500 | delete [] encrypted; |
1501 | delete [] decrypted; | 1501 | delete [] decrypted; |
1502 | return e_cryptNotImpl; | 1502 | return e_cryptNotImpl; |
1503 | } } | 1503 | } } |
1504 | delete [] encrypted; | 1504 | delete [] encrypted; |
1505 | #ifndef PWM_EMBEDDED | 1505 | #ifndef PWM_EMBEDDED |
1506 | d->assign(reinterpret_cast<const char *>(decrypted), | 1506 | d->assign(reinterpret_cast<const char *>(decrypted), |
1507 | static_cast<string::size_type>(cryptLen)); | 1507 | static_cast<string::size_type>(cryptLen)); |
1508 | #else | 1508 | #else |
1509 | d->assign((const char *)(decrypted), | 1509 | d->assign((const char *)(decrypted), |
1510 | (string::size_type)(cryptLen)); | 1510 | (string::size_type)(cryptLen)); |
1511 | #endif | 1511 | #endif |
1512 | delete [] decrypted; | 1512 | delete [] decrypted; |
1513 | if (algo == PWM_CRYPT_BLOWFISH) { | 1513 | if (algo == PWM_CRYPT_BLOWFISH) { |
1514 | if (!Blowfish::unpadNull(d)) { | 1514 | if (!Blowfish::unpadNull(d)) { |
1515 | BUG(); | 1515 | BUG(); |
1516 | return e_readFile; | 1516 | return e_readFile; |
1517 | } | 1517 | } |
1518 | } | 1518 | } |
1519 | return e_success; | 1519 | return e_success; |
1520 | } | 1520 | } |
1521 | 1521 | ||
1522 | PwMerror PwMDoc::checkDataHash(char dataHashType, const string *dataHash, | 1522 | PwMerror PwMDoc::checkDataHash(char dataHashType, const string *dataHash, |
1523 | const string *dataStream) | 1523 | const string *dataStream) |
1524 | { | 1524 | { |
1525 | PWM_ASSERT(dataHash); | 1525 | PWM_ASSERT(dataHash); |
1526 | PWM_ASSERT(dataStream); | 1526 | PWM_ASSERT(dataStream); |
1527 | switch(dataHashType) { | 1527 | switch(dataHashType) { |
1528 | case PWM_HASH_SHA1: { | 1528 | case PWM_HASH_SHA1: { |
1529 | Sha1 hash; | 1529 | Sha1 hash; |
1530 | hash.sha1_write((byte*)dataStream->c_str(), dataStream->length()); | 1530 | hash.sha1_write((byte*)dataStream->c_str(), dataStream->length()); |
1531 | string ret = hash.sha1_read(); | 1531 | string ret = hash.sha1_read(); |
1532 | if (ret != *dataHash) | 1532 | if (ret != *dataHash) |
1533 | return e_fileCorrupt; | 1533 | return e_fileCorrupt; |
1534 | break; | 1534 | break; |
1535 | } | 1535 | } |
1536 | case PWM_HASH_SHA256: | 1536 | case PWM_HASH_SHA256: |
1537 | /*... fall through */ | 1537 | /*... fall through */ |
1538 | case PWM_HASH_SHA384: | 1538 | case PWM_HASH_SHA384: |
1539 | case PWM_HASH_SHA512: | 1539 | case PWM_HASH_SHA512: |
1540 | case PWM_HASH_MD5: | 1540 | case PWM_HASH_MD5: |
1541 | case PWM_HASH_RMD160: | 1541 | case PWM_HASH_RMD160: |
1542 | case PWM_HASH_TIGER: { | 1542 | case PWM_HASH_TIGER: { |
1543 | if (!LibGCryptIf::available()) | 1543 | if (!LibGCryptIf::available()) |
1544 | return e_hashNotImpl; | 1544 | return e_hashNotImpl; |
1545 | LibGCryptIf gc; | 1545 | LibGCryptIf gc; |
1546 | PwMerror err; | 1546 | PwMerror err; |
1547 | unsigned char *buf; | 1547 | unsigned char *buf; |
1548 | size_t hashLen; | 1548 | size_t hashLen; |
1549 | err = gc.hash(&buf, | 1549 | err = gc.hash(&buf, |
1550 | &hashLen, | 1550 | &hashLen, |
1551 | reinterpret_cast<const unsigned char *>(dataStream->c_str()), | 1551 | reinterpret_cast<const unsigned char *>(dataStream->c_str()), |
1552 | dataStream->length(), | 1552 | dataStream->length(), |
1553 | dataHashType); | 1553 | dataHashType); |
1554 | if (err != e_success) | 1554 | if (err != e_success) |
1555 | return e_hashNotImpl; | 1555 | return e_hashNotImpl; |
1556 | string calcHash(reinterpret_cast<const char *>(buf), | 1556 | string calcHash(reinterpret_cast<const char *>(buf), |
1557 | static_cast<string::size_type>(hashLen)); | 1557 | static_cast<string::size_type>(hashLen)); |
1558 | delete [] buf; | 1558 | delete [] buf; |
1559 | if (calcHash != *dataHash) | 1559 | if (calcHash != *dataHash) |
1560 | return e_fileCorrupt; | 1560 | return e_fileCorrupt; |
1561 | break; | 1561 | break; |
1562 | } | 1562 | } |
1563 | default: | 1563 | default: |
1564 | return e_hashNotImpl; | 1564 | return e_hashNotImpl; |
1565 | } | 1565 | } |
1566 | return e_success; | 1566 | return e_success; |
1567 | } | 1567 | } |
1568 | 1568 | ||
1569 | bool PwMDoc::lockAt(unsigned int category, unsigned int index, | 1569 | bool PwMDoc::lockAt(unsigned int category, unsigned int index, |
1570 | bool lock) | 1570 | bool lock) |
1571 | { | 1571 | { |
1572 | if (index >= numEntries(category)) { | 1572 | if (index >= numEntries(category)) { |
1573 | BUG(); | 1573 | BUG(); |
1574 | return false; | 1574 | return false; |
1575 | } | 1575 | } |
1576 | if (lock == dti.dta[category].d[index].lockStat) | 1576 | if (lock == dti.dta[category].d[index].lockStat) |
1577 | return true; | 1577 | return true; |
1578 | 1578 | ||
1579 | if (!lock && currentPw != "") { | 1579 | if (!lock && currentPw != "") { |
1580 | // "unlocking" and "password is already set" | 1580 | // "unlocking" and "password is already set" |
1581 | if (!getDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW)) { | 1581 | if (!getDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW)) { |
1582 | // unlocking without pw not allowed | 1582 | // unlocking without pw not allowed |
1583 | QString pw; | 1583 | QString pw; |
1584 | pw = requestMpw(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); | 1584 | pw = requestMpw(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); |
1585 | if (pw != "") { | 1585 | if (pw != "") { |
1586 | if (pw != currentPw) { | 1586 | if (pw != currentPw) { |
1587 | wrongMpwMsgBox(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); | 1587 | wrongMpwMsgBox(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); |
1588 | return false; | 1588 | return false; |
1589 | } else { | 1589 | } else { |
1590 | timer()->start(DocTimer::id_mpwTimer); | 1590 | timer()->start(DocTimer::id_mpwTimer); |
1591 | } | 1591 | } |
1592 | } else { | 1592 | } else { |
1593 | return false; | 1593 | return false; |
1594 | } | 1594 | } |
1595 | } else { | 1595 | } else { |
1596 | timer()->start(DocTimer::id_mpwTimer); | 1596 | timer()->start(DocTimer::id_mpwTimer); |
1597 | } | 1597 | } |
1598 | } | 1598 | } |
1599 | 1599 | ||
1600 | dti.dta[category].d[index].lockStat = lock; | 1600 | dti.dta[category].d[index].lockStat = lock; |
1601 | dti.dta[category].d[index].rev++; // increment revision counter. | 1601 | dti.dta[category].d[index].rev++; // increment revision counter. |
1602 | 1602 | ||
1603 | emitDataChanged(this); | 1603 | emitDataChanged(this); |
1604 | if (!lock) | 1604 | if (!lock) |
1605 | timer()->start(DocTimer::id_autoLockTimer); | 1605 | timer()->start(DocTimer::id_autoLockTimer); |
1606 | 1606 | ||
1607 | return true; | 1607 | return true; |
1608 | 1608 | ||
1609 | } | 1609 | } |
1610 | 1610 | ||
1611 | bool PwMDoc::lockAt(const QString &category,unsigned int index, | 1611 | bool PwMDoc::lockAt(const QString &category,unsigned int index, |
1612 | bool lock) | 1612 | bool lock) |
1613 | { | 1613 | { |
1614 | unsigned int cat = 0; | 1614 | unsigned int cat = 0; |
1615 | 1615 | ||
1616 | if (!findCategory(category, &cat)) { | 1616 | if (!findCategory(category, &cat)) { |
1617 | BUG(); | 1617 | BUG(); |
1618 | return false; | 1618 | return false; |
1619 | } | 1619 | } |
1620 | 1620 | ||
1621 | return lockAt(cat, index, lock); | 1621 | return lockAt(cat, index, lock); |
1622 | } | 1622 | } |
1623 | 1623 | ||
1624 | bool PwMDoc::lockAll(bool lock) | 1624 | bool PwMDoc::lockAll(bool lock) |
1625 | { | 1625 | { |
1626 | if (!lock && isDeepLocked()) { | 1626 | if (!lock && isDeepLocked()) { |
1627 | PwMerror ret; | 1627 | PwMerror ret; |
1628 | ret = deepLock(false); | 1628 | ret = deepLock(false); |
1629 | if (ret != e_success) | 1629 | if (ret != e_success) |
1630 | return false; | 1630 | return false; |
1631 | return true; | 1631 | return true; |
1632 | } | 1632 | } |
1633 | if (isDocEmpty()) { | 1633 | if (isDocEmpty()) { |
1634 | return true; | 1634 | return true; |
1635 | } | 1635 | } |
1636 | if (!lock && currentPw != "") { | 1636 | if (!lock && currentPw != "") { |
1637 | // unlocking and password is already set | 1637 | // unlocking and password is already set |
1638 | if (!getDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW)) { | 1638 | if (!getDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW)) { |
1639 | // unlocking without pw not allowed | 1639 | // unlocking without pw not allowed |
1640 | QString pw; | 1640 | QString pw; |
1641 | pw = requestMpw(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); | 1641 | pw = requestMpw(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); |
1642 | if (pw != "") { | 1642 | if (pw != "") { |
1643 | if (pw != currentPw) { | 1643 | if (pw != currentPw) { |
1644 | wrongMpwMsgBox(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); | 1644 | wrongMpwMsgBox(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); |
1645 | return false; | 1645 | return false; |
1646 | } else { | 1646 | } else { |
1647 | timer()->start(DocTimer::id_mpwTimer); | 1647 | timer()->start(DocTimer::id_mpwTimer); |
1648 | } | 1648 | } |
1649 | } else { | 1649 | } else { |
1650 | return false; | 1650 | return false; |
1651 | } | 1651 | } |
1652 | } else { | 1652 | } else { |
1653 | timer()->start(DocTimer::id_mpwTimer); | 1653 | timer()->start(DocTimer::id_mpwTimer); |
1654 | } | 1654 | } |
1655 | } | 1655 | } |
1656 | 1656 | ||
1657 | vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(), | 1657 | vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(), |
1658 | catEnd = dti.dta.end(), | 1658 | catEnd = dti.dta.end(), |
1659 | catI = catBegin; | 1659 | catI = catBegin; |
1660 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; | 1660 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; |
1661 | while (catI != catEnd) { | 1661 | while (catI != catEnd) { |
1662 | entrBegin = catI->d.begin(); | 1662 | entrBegin = catI->d.begin(); |
1663 | entrEnd = catI->d.end(); | 1663 | entrEnd = catI->d.end(); |
1664 | entrI = entrBegin; | 1664 | entrI = entrBegin; |
1665 | while (entrI != entrEnd) { | 1665 | while (entrI != entrEnd) { |
1666 | entrI->lockStat = lock; | 1666 | entrI->lockStat = lock; |
1667 | entrI->rev++; // increment revision counter. | 1667 | entrI->rev++; // increment revision counter. |
1668 | ++entrI; | 1668 | ++entrI; |
1669 | } | 1669 | } |
1670 | ++catI; | 1670 | ++catI; |
1671 | } | 1671 | } |
1672 | 1672 | ||
1673 | emitDataChanged(this); | 1673 | emitDataChanged(this); |
1674 | if (lock) | 1674 | if (lock) |
1675 | timer()->stop(DocTimer::id_autoLockTimer); | 1675 | timer()->stop(DocTimer::id_autoLockTimer); |
1676 | else | 1676 | else |
1677 | timer()->start(DocTimer::id_autoLockTimer); | 1677 | timer()->start(DocTimer::id_autoLockTimer); |
1678 | 1678 | ||
1679 | return true; | 1679 | return true; |
1680 | } | 1680 | } |
1681 | 1681 | ||
1682 | bool PwMDoc::isLocked(const QString &category, unsigned int index) | 1682 | bool PwMDoc::isLocked(const QString &category, unsigned int index) |
1683 | { | 1683 | { |
1684 | unsigned int cat = 0; | 1684 | unsigned int cat = 0; |
1685 | 1685 | ||
1686 | if (!findCategory(category, &cat)) { | 1686 | if (!findCategory(category, &cat)) { |
1687 | BUG(); | 1687 | BUG(); |
1688 | return false; | 1688 | return false; |
1689 | } | 1689 | } |
1690 | 1690 | ||
1691 | return isLocked(cat, index); | 1691 | return isLocked(cat, index); |
1692 | } | 1692 | } |
1693 | 1693 | ||
1694 | bool PwMDoc::unlockAll_tempoary(bool revert) | 1694 | bool PwMDoc::unlockAll_tempoary(bool revert) |
1695 | { | 1695 | { |
1696 | static vector< vector<bool> > *oldLockStates = 0; | 1696 | static vector< vector<bool> > *oldLockStates = 0; |
1697 | static bool wasDeepLocked; | 1697 | static bool wasDeepLocked; |
1698 | 1698 | ||
1699 | if (revert) {// revert the unlocking | 1699 | if (revert) {// revert the unlocking |
1700 | if (oldLockStates) { | 1700 | if (oldLockStates) { |
1701 | /* we actually _have_ unlocked something, because | 1701 | /* we actually _have_ unlocked something, because |
1702 | * we have allocated space for the oldLockStates. | 1702 | * we have allocated space for the oldLockStates. |
1703 | * So, go on and revert them! | 1703 | * So, go on and revert them! |
1704 | */ | 1704 | */ |
1705 | if (wasDeepLocked) { | 1705 | if (wasDeepLocked) { |
1706 | PwMerror ret = deepLock(true); | 1706 | PwMerror ret = deepLock(true); |
1707 | if (ret == e_success) { | 1707 | if (ret == e_success) { |
1708 | /* deep-lock succeed. We are save. | 1708 | /* deep-lock succeed. We are save. |
1709 | * (but if it failed, just go on | 1709 | * (but if it failed, just go on |
1710 | * lock them normally) | 1710 | * lock them normally) |
1711 | */ | 1711 | */ |
1712 | delete_and_null(oldLockStates); | 1712 | delete_and_null(oldLockStates); |
1713 | timer()->start(DocTimer::id_autoLockTimer); | 1713 | timer()->start(DocTimer::id_autoLockTimer); |
1714 | printDebug("tempoary unlocking of dta " | 1714 | printDebug("tempoary unlocking of dta " |
1715 | "reverted by deep-locking."); | 1715 | "reverted by deep-locking."); |
1716 | return true; | 1716 | return true; |
1717 | } | 1717 | } |
1718 | printDebug("deep-lock failed while reverting! " | 1718 | printDebug("deep-lock failed while reverting! " |
1719 | "Falling back to normal-lock."); | 1719 | "Falling back to normal-lock."); |
1720 | } | 1720 | } |
1721 | if (unlikely(!wasDeepLocked && | 1721 | if (unlikely(!wasDeepLocked && |
1722 | numCategories() != oldLockStates->size())) { | 1722 | numCategories() != oldLockStates->size())) { |
1723 | /* DOH! We have modified "dta" while | 1723 | /* DOH! We have modified "dta" while |
1724 | * it was unlocked tempoary. DON'T DO THIS! | 1724 | * it was unlocked tempoary. DON'T DO THIS! |
1725 | */ | 1725 | */ |
1726 | BUG(); | 1726 | BUG(); |
1727 | delete_and_null(oldLockStates); | 1727 | delete_and_null(oldLockStates); |
1728 | timer()->start(DocTimer::id_autoLockTimer); | 1728 | timer()->start(DocTimer::id_autoLockTimer); |
1729 | return false; | 1729 | return false; |
1730 | } | 1730 | } |
1731 | vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(), | 1731 | vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(), |
1732 | catEnd = dti.dta.end(), | 1732 | catEnd = dti.dta.end(), |
1733 | catI = catBegin; | 1733 | catI = catBegin; |
1734 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; | 1734 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; |
1735 | vector< vector<bool> >::iterator oldCatStatI = oldLockStates->begin(); | 1735 | vector< vector<bool> >::iterator oldCatStatI = oldLockStates->begin(); |
1736 | vector<bool>::iterator oldEntrStatBegin, | 1736 | vector<bool>::iterator oldEntrStatBegin, |
1737 | oldEntrStatEnd, | 1737 | oldEntrStatEnd, |
1738 | oldEntrStatI; | 1738 | oldEntrStatI; |
1739 | while (catI != catEnd) { | 1739 | while (catI != catEnd) { |
1740 | entrBegin = catI->d.begin(); | 1740 | entrBegin = catI->d.begin(); |
1741 | entrEnd = catI->d.end(); | 1741 | entrEnd = catI->d.end(); |
1742 | entrI = entrBegin; | 1742 | entrI = entrBegin; |
1743 | if (likely(!wasDeepLocked)) { | 1743 | if (likely(!wasDeepLocked)) { |
1744 | oldEntrStatBegin = oldCatStatI->begin(); | 1744 | oldEntrStatBegin = oldCatStatI->begin(); |
1745 | oldEntrStatEnd = oldCatStatI->end(); | 1745 | oldEntrStatEnd = oldCatStatI->end(); |
1746 | oldEntrStatI = oldEntrStatBegin; | 1746 | oldEntrStatI = oldEntrStatBegin; |
1747 | if (unlikely(catI->d.size() != oldCatStatI->size())) { | 1747 | if (unlikely(catI->d.size() != oldCatStatI->size())) { |
1748 | /* DOH! We have modified "dta" while | 1748 | /* DOH! We have modified "dta" while |
1749 | * it was unlocked tempoary. DON'T DO THIS! | 1749 | * it was unlocked tempoary. DON'T DO THIS! |
1750 | */ | 1750 | */ |
1751 | BUG(); | 1751 | BUG(); |
1752 | delete_and_null(oldLockStates); | 1752 | delete_and_null(oldLockStates); |
1753 | timer()->start(DocTimer::id_autoLockTimer); | 1753 | timer()->start(DocTimer::id_autoLockTimer); |
1754 | return false; | 1754 | return false; |
1755 | } | 1755 | } |
1756 | } | 1756 | } |
1757 | while (entrI != entrEnd) { | 1757 | while (entrI != entrEnd) { |
1758 | if (wasDeepLocked) { | 1758 | if (wasDeepLocked) { |
1759 | /* this is an error-fallback if | 1759 | /* this is an error-fallback if |
1760 | * deeplock didn't succeed | 1760 | * deeplock didn't succeed |
1761 | */ | 1761 | */ |
1762 | entrI->lockStat = true; | 1762 | entrI->lockStat = true; |
1763 | } else { | 1763 | } else { |
1764 | entrI->lockStat = *oldEntrStatI; | 1764 | entrI->lockStat = *oldEntrStatI; |
1765 | } | 1765 | } |
1766 | ++entrI; | 1766 | ++entrI; |
1767 | if (likely(!wasDeepLocked)) | 1767 | if (likely(!wasDeepLocked)) |
1768 | ++oldEntrStatI; | 1768 | ++oldEntrStatI; |
1769 | } | 1769 | } |
1770 | ++catI; | 1770 | ++catI; |
1771 | if (likely(!wasDeepLocked)) | 1771 | if (likely(!wasDeepLocked)) |
1772 | ++oldCatStatI; | 1772 | ++oldCatStatI; |
1773 | } | 1773 | } |
1774 | delete_and_null(oldLockStates); | 1774 | delete_and_null(oldLockStates); |
1775 | if (unlikely(wasDeepLocked)) { | 1775 | if (unlikely(wasDeepLocked)) { |
1776 | /* error fallback... */ | 1776 | /* error fallback... */ |
1777 | unsetDocStatFlag(DOC_STAT_DEEPLOCKED); | 1777 | unsetDocStatFlag(DOC_STAT_DEEPLOCKED); |
1778 | emitDataChanged(this); | 1778 | emitDataChanged(this); |
1779 | printDebug("WARNING: unlockAll_tempoary(true) " | 1779 | printDebug("WARNING: unlockAll_tempoary(true) " |
1780 | "deeplock fallback!"); | 1780 | "deeplock fallback!"); |
1781 | } | 1781 | } |
1782 | printDebug("tempoary unlocking of dta reverted."); | 1782 | printDebug("tempoary unlocking of dta reverted."); |
1783 | } else { | 1783 | } else { |
1784 | printDebug("unlockAll_tempoary(true): nothing to do."); | 1784 | printDebug("unlockAll_tempoary(true): nothing to do."); |
1785 | } | 1785 | } |
1786 | timer()->start(DocTimer::id_autoLockTimer); | 1786 | timer()->start(DocTimer::id_autoLockTimer); |
1787 | } else {// unlock all data tempoary | 1787 | } else {// unlock all data tempoary |
1788 | if (unlikely(oldLockStates != 0)) { | 1788 | if (unlikely(oldLockStates != 0)) { |
1789 | /* DOH! We have already unlocked the data tempoarly. | 1789 | /* DOH! We have already unlocked the data tempoarly. |
1790 | * No need to do it twice. ;) | 1790 | * No need to do it twice. ;) |
1791 | */ | 1791 | */ |
1792 | BUG(); | 1792 | BUG(); |
1793 | return false; | 1793 | return false; |
1794 | } | 1794 | } |
1795 | wasDeepLocked = false; | 1795 | wasDeepLocked = false; |
1796 | bool mustUnlock = false; | 1796 | bool mustUnlock = false; |
1797 | if (isDeepLocked()) { | 1797 | if (isDeepLocked()) { |
1798 | PwMerror ret; | 1798 | PwMerror ret; |
1799 | while (1) { | 1799 | while (1) { |
1800 | ret = deepLock(false); | 1800 | ret = deepLock(false); |
1801 | if (ret == e_success) { | 1801 | if (ret == e_success) { |
1802 | break; | 1802 | break; |
1803 | } else if (ret == e_wrongPw) { | 1803 | } else if (ret == e_wrongPw) { |
1804 | wrongMpwMsgBox(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); | 1804 | wrongMpwMsgBox(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); |
1805 | } else { | 1805 | } else { |
1806 | printDebug("deep-unlocking failed while " | 1806 | printDebug("deep-unlocking failed while " |
1807 | "tempoary unlocking!"); | 1807 | "tempoary unlocking!"); |
1808 | return false; | 1808 | return false; |
1809 | } | 1809 | } |
1810 | } | 1810 | } |
1811 | wasDeepLocked = true; | 1811 | wasDeepLocked = true; |
1812 | mustUnlock = true; | 1812 | mustUnlock = true; |
1813 | } else { | 1813 | } else { |
1814 | // first check if it's needed to unlock some entries | 1814 | // first check if it's needed to unlock some entries |
1815 | vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(), | 1815 | vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(), |
1816 | catEnd = dti.dta.end(), | 1816 | catEnd = dti.dta.end(), |
1817 | catI = catBegin; | 1817 | catI = catBegin; |
1818 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; | 1818 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; |
1819 | while (catI != catEnd) { | 1819 | while (catI != catEnd) { |
1820 | entrBegin = catI->d.begin(); | 1820 | entrBegin = catI->d.begin(); |
1821 | entrEnd = catI->d.end(); | 1821 | entrEnd = catI->d.end(); |
1822 | entrI = entrBegin; | 1822 | entrI = entrBegin; |
1823 | while (entrI != entrEnd) { | 1823 | while (entrI != entrEnd) { |
1824 | if (entrI->lockStat == true) { | 1824 | if (entrI->lockStat == true) { |
1825 | mustUnlock = true; | 1825 | mustUnlock = true; |
1826 | break; | 1826 | break; |
1827 | } | 1827 | } |
1828 | ++entrI; | 1828 | ++entrI; |
1829 | } | 1829 | } |
1830 | if (mustUnlock) | 1830 | if (mustUnlock) |
1831 | break; | 1831 | break; |
1832 | ++catI; | 1832 | ++catI; |
1833 | } | 1833 | } |
1834 | } | 1834 | } |
1835 | if (!mustUnlock) { | 1835 | if (!mustUnlock) { |
1836 | // nothing to do. | 1836 | // nothing to do. |
1837 | timer()->stop(DocTimer::id_autoLockTimer); | 1837 | timer()->stop(DocTimer::id_autoLockTimer); |
1838 | printDebug("unlockAll_tempoary(): nothing to do."); | 1838 | printDebug("unlockAll_tempoary(): nothing to do."); |
1839 | return true; | 1839 | return true; |
1840 | } else if (!wasDeepLocked) { | 1840 | } else if (!wasDeepLocked) { |
1841 | if (!getDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW) && | 1841 | if (!getDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW) && |
1842 | currentPw != "") { | 1842 | currentPw != "") { |
1843 | /* we can't unlock without mpw, so | 1843 | /* we can't unlock without mpw, so |
1844 | * we need to ask for it. | 1844 | * we need to ask for it. |
1845 | */ | 1845 | */ |
1846 | QString pw; | 1846 | QString pw; |
1847 | while (1) { | 1847 | while (1) { |
1848 | pw = requestMpw(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); | 1848 | pw = requestMpw(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); |
1849 | if (pw == "") { | 1849 | if (pw == "") { |
1850 | return false; | 1850 | return false; |
1851 | } else if (pw == currentPw) { | 1851 | } else if (pw == currentPw) { |
1852 | break; | 1852 | break; |
1853 | } | 1853 | } |
1854 | wrongMpwMsgBox(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); | 1854 | wrongMpwMsgBox(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); |
1855 | } | 1855 | } |
1856 | } | 1856 | } |
1857 | } | 1857 | } |
1858 | timer()->stop(DocTimer::id_autoLockTimer); | 1858 | timer()->stop(DocTimer::id_autoLockTimer); |
1859 | oldLockStates = new vector< vector<bool> >; | 1859 | oldLockStates = new vector< vector<bool> >; |
1860 | vector<bool> tmp_vec; | 1860 | vector<bool> tmp_vec; |
1861 | vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(), | 1861 | vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(), |
1862 | catEnd = dti.dta.end(), | 1862 | catEnd = dti.dta.end(), |
1863 | catI = catBegin; | 1863 | catI = catBegin; |
1864 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; | 1864 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; |
1865 | while (catI != catEnd) { | 1865 | while (catI != catEnd) { |
1866 | entrBegin = catI->d.begin(); | 1866 | entrBegin = catI->d.begin(); |
1867 | entrEnd = catI->d.end(); | 1867 | entrEnd = catI->d.end(); |
1868 | entrI = entrBegin; | 1868 | entrI = entrBegin; |
1869 | while (entrI != entrEnd) { | 1869 | while (entrI != entrEnd) { |
1870 | if (!wasDeepLocked) { | 1870 | if (!wasDeepLocked) { |
1871 | tmp_vec.push_back(entrI->lockStat); | 1871 | tmp_vec.push_back(entrI->lockStat); |
1872 | } | 1872 | } |
1873 | entrI->lockStat = false; | 1873 | entrI->lockStat = false; |
1874 | ++entrI; | 1874 | ++entrI; |
1875 | } | 1875 | } |
1876 | if (!wasDeepLocked) { | 1876 | if (!wasDeepLocked) { |
1877 | oldLockStates->push_back(tmp_vec); | 1877 | oldLockStates->push_back(tmp_vec); |
1878 | tmp_vec.clear(); | 1878 | tmp_vec.clear(); |
1879 | } | 1879 | } |
1880 | ++catI; | 1880 | ++catI; |
1881 | } | 1881 | } |
1882 | printDebug("tempoary unlocked dta."); | 1882 | printDebug("tempoary unlocked dta."); |
1883 | } | 1883 | } |
1884 | 1884 | ||
1885 | return true; | 1885 | return true; |
1886 | } | 1886 | } |
1887 | 1887 | ||
1888 | PwMerror PwMDoc::deepLock(bool lock, bool saveToFile) | 1888 | PwMerror PwMDoc::deepLock(bool lock, bool saveToFile) |
1889 | { | 1889 | { |
1890 | PwMerror ret; | 1890 | PwMerror ret; |
1891 | /* NOTE: saveDoc() depends on this function to return | 1891 | /* NOTE: saveDoc() depends on this function to return |
1892 | * e_success if saveToFile == false | 1892 | * e_success if saveToFile == false |
1893 | */ | 1893 | */ |
1894 | 1894 | ||
1895 | if (lock) { | 1895 | if (lock) { |
1896 | if (isDeepLocked()) | 1896 | if (isDeepLocked()) |
1897 | return e_lock; | 1897 | return e_lock; |
1898 | if (saveToFile) { | 1898 | if (saveToFile) { |
1899 | if (isDocEmpty()) | 1899 | if (isDocEmpty()) |
1900 | return e_docIsEmpty; | 1900 | return e_docIsEmpty; |
1901 | ret = saveDoc(conf()->confGlobCompression()); | 1901 | ret = saveDoc(conf()->confGlobCompression()); |
1902 | if (ret == e_filename) { | 1902 | if (ret == e_filename) { |
1903 | /* the doc wasn't saved to a file | 1903 | /* the doc wasn't saved to a file |
1904 | * by the user, yet. | 1904 | * by the user, yet. |
1905 | */ | 1905 | */ |
1906 | cantDeeplock_notSavedMsgBox(); | 1906 | cantDeeplock_notSavedMsgBox(); |
1907 | return e_docNotSaved; | 1907 | return e_docNotSaved; |
1908 | } else if (ret != e_success) { | 1908 | } else if (ret != e_success) { |
1909 | return e_lock; | 1909 | return e_lock; |
1910 | } | 1910 | } |
1911 | } | 1911 | } |
1912 | timer()->stop(DocTimer::id_autoLockTimer); | 1912 | timer()->stop(DocTimer::id_autoLockTimer); |
1913 | clearDoc(); | 1913 | clearDoc(); |
1914 | PwMDataItem d; | 1914 | PwMDataItem d; |
1915 | d.desc = IS_DEEPLOCKED_SHORTMSG.latin1(); | 1915 | d.desc = IS_DEEPLOCKED_SHORTMSG.latin1(); |
1916 | d.comment = IS_DEEPLOCKED_MSG.latin1(); | 1916 | d.comment = IS_DEEPLOCKED_MSG.latin1(); |
1917 | d.listViewPos = 0; | 1917 | d.listViewPos = 0; |
1918 | addEntry(DEFAULT_CATEGORY, &d, true); | 1918 | addEntry(DEFAULT_CATEGORY, &d, true); |
1919 | lockAt(DEFAULT_CATEGORY, 0, true); | 1919 | lockAt(DEFAULT_CATEGORY, 0, true); |
1920 | unsetDocStatFlag(DOC_STAT_DISK_DIRTY); | 1920 | unsetDocStatFlag(DOC_STAT_DISK_DIRTY); |
1921 | setDocStatFlag(DOC_STAT_DEEPLOCKED); | 1921 | setDocStatFlag(DOC_STAT_DEEPLOCKED); |
1922 | } else { | 1922 | } else { |
1923 | if (!isDeepLocked()) | 1923 | if (!isDeepLocked()) |
1924 | return e_lock; | 1924 | return e_lock; |
1925 | ret = openDoc(&filename, (conf()->confGlobUnlockOnOpen()) | 1925 | ret = openDoc(&filename, (conf()->confGlobUnlockOnOpen()) |
1926 | ? 0 : 1); | 1926 | ? 0 : 1); |
1927 | if (ret == e_wrongPw) { | 1927 | if (ret == e_wrongPw) { |
1928 | return e_wrongPw; | 1928 | return e_wrongPw; |
1929 | } else if (ret != e_success) { | 1929 | } else if (ret != e_success) { |
1930 | printDebug(string("PwMDoc::deepLock(false): ERR! openDoc() == ") | 1930 | printDebug(string("PwMDoc::deepLock(false): ERR! openDoc() == ") |
1931 | + tostr(static_cast<int>(ret))); | 1931 | + tostr(static_cast<int>(ret))); |
1932 | return e_lock; | 1932 | return e_lock; |
1933 | } | 1933 | } |
1934 | unsetDocStatFlag(DOC_STAT_DEEPLOCKED); | 1934 | unsetDocStatFlag(DOC_STAT_DEEPLOCKED); |
1935 | timer()->start(DocTimer::id_autoLockTimer); | 1935 | timer()->start(DocTimer::id_autoLockTimer); |
1936 | } | 1936 | } |
1937 | 1937 | ||
1938 | emitDataChanged(this); | 1938 | emitDataChanged(this); |
1939 | return e_success; | 1939 | return e_success; |
1940 | } | 1940 | } |
1941 | 1941 | ||
1942 | void PwMDoc::_deepUnlock() | 1942 | void PwMDoc::_deepUnlock() |
1943 | { | 1943 | { |
1944 | deepLock(false); | 1944 | deepLock(false); |
1945 | } | 1945 | } |
1946 | 1946 | ||
1947 | void PwMDoc::clearDoc() | 1947 | void PwMDoc::clearDoc() |
1948 | { | 1948 | { |
1949 | dti.clear(); | 1949 | dti.clear(); |
1950 | PwMCategoryItem d; | 1950 | PwMCategoryItem d; |
1951 | //US ENH: to initialize all members with meaningfull data. | 1951 | //US ENH: to initialize all members with meaningfull data. |
1952 | d.clear(); | 1952 | d.clear(); |
1953 | d.name = DEFAULT_CATEGORY.latin1(); | 1953 | d.name = DEFAULT_CATEGORY.latin1(); |
1954 | dti.dta.push_back(d); | 1954 | dti.dta.push_back(d); |
1955 | currentPw = ""; | 1955 | currentPw = ""; |
1956 | unsetDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW); | 1956 | unsetDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW); |
1957 | } | 1957 | } |
1958 | 1958 | ||
1959 | void PwMDoc::changeCurrentPw() | 1959 | void PwMDoc::changeCurrentPw() |
1960 | { | 1960 | { |
1961 | if (currentPw == "") | 1961 | if (currentPw == "") |
1962 | return; // doc hasn't been saved. No mpw available. | 1962 | return; // doc hasn't been saved. No mpw available. |
1963 | bool useChipcard = getDocStatFlag(DOC_STAT_USE_CHIPCARD); | 1963 | bool useChipcard = getDocStatFlag(DOC_STAT_USE_CHIPCARD); |
1964 | QString pw = requestMpwChange(¤tPw, &useChipcard); | 1964 | QString pw = requestMpwChange(¤tPw, &useChipcard); |
1965 | if (pw == "") | 1965 | if (pw == "") |
1966 | return; | 1966 | return; |
1967 | if (useChipcard) | 1967 | if (useChipcard) |
1968 | setDocStatFlag(DOC_STAT_USE_CHIPCARD); | 1968 | setDocStatFlag(DOC_STAT_USE_CHIPCARD); |
1969 | else | 1969 | else |
1970 | unsetDocStatFlag(DOC_STAT_USE_CHIPCARD); | 1970 | unsetDocStatFlag(DOC_STAT_USE_CHIPCARD); |
1971 | setCurrentPw(pw); | 1971 | setCurrentPw(pw); |
1972 | } | 1972 | } |
1973 | 1973 | ||
1974 | void PwMDoc::setListViewPos(const QString &category, unsigned int index, | 1974 | void PwMDoc::setListViewPos(const QString &category, unsigned int index, |
1975 | int pos) | 1975 | int pos) |
1976 | { | 1976 | { |
1977 | unsigned int cat = 0; | 1977 | unsigned int cat = 0; |
1978 | 1978 | ||
1979 | if (!findCategory(category, &cat)) { | 1979 | if (!findCategory(category, &cat)) { |
1980 | BUG(); | 1980 | BUG(); |
1981 | return; | 1981 | return; |
1982 | } | 1982 | } |
1983 | setListViewPos(cat, index, pos); | 1983 | setListViewPos(cat, index, pos); |
1984 | } | 1984 | } |
1985 | 1985 | ||
1986 | void PwMDoc::setListViewPos(unsigned int category, unsigned int index, | 1986 | void PwMDoc::setListViewPos(unsigned int category, unsigned int index, |
1987 | int pos) | 1987 | int pos) |
1988 | { | 1988 | { |
1989 | dti.dta[category].d[index].listViewPos = pos; | 1989 | dti.dta[category].d[index].listViewPos = pos; |
1990 | 1990 | ||
1991 | /* FIXME workaround: don't flag dirty, because this function sometimes | 1991 | /* FIXME workaround: don't flag dirty, because this function sometimes |
1992 | * get's called when it shouldn't. It's because PwMView assumes | 1992 | * get's called when it shouldn't. It's because PwMView assumes |
1993 | * the user resorted the UI on behalf of signal layoutChanged(). | 1993 | * the user resorted the UI on behalf of signal layoutChanged(). |
1994 | * This is somewhat broken and incorrect, but I've no other | 1994 | * This is somewhat broken and incorrect, but I've no other |
1995 | * solution for now. | 1995 | * solution for now. |
1996 | */ | 1996 | */ |
1997 | //setDocStatFlag(DOC_STAT_DISK_DIRTY); | 1997 | //setDocStatFlag(DOC_STAT_DISK_DIRTY); |
1998 | } | 1998 | } |
1999 | 1999 | ||
2000 | int PwMDoc::getListViewPos(const QString &category, unsigned int index) | 2000 | int PwMDoc::getListViewPos(const QString &category, unsigned int index) |
2001 | { | 2001 | { |
2002 | unsigned int cat = 0; | 2002 | unsigned int cat = 0; |
2003 | 2003 | ||
2004 | if (!findCategory(category, &cat)) { | 2004 | if (!findCategory(category, &cat)) { |
2005 | BUG(); | 2005 | BUG(); |
2006 | return -1; | 2006 | return -1; |
2007 | } | 2007 | } |
2008 | 2008 | ||
2009 | return dti.dta[cat].d[index].listViewPos; | 2009 | return dti.dta[cat].d[index].listViewPos; |
2010 | } | 2010 | } |
2011 | 2011 | ||
2012 | void PwMDoc::findEntry(unsigned int category, PwMDataItem find, unsigned int searchIn, | 2012 | void PwMDoc::findEntry(unsigned int category, PwMDataItem find, unsigned int searchIn, |
2013 | vector<unsigned int> *foundPositions, bool breakAfterFound, | 2013 | vector<unsigned int> *foundPositions, bool breakAfterFound, |
2014 | bool caseSensitive, bool exactWordMatch, bool sortByLvp) | 2014 | bool caseSensitive, bool exactWordMatch, bool sortByLvp) |
2015 | { | 2015 | { |
2016 | PWM_ASSERT(foundPositions); | 2016 | PWM_ASSERT(foundPositions); |
2017 | PWM_ASSERT(searchIn); | 2017 | PWM_ASSERT(searchIn); |
2018 | foundPositions->clear(); | 2018 | foundPositions->clear(); |
2019 | 2019 | ||
2020 | unsigned int i, entries = numEntries(category); | 2020 | unsigned int i, entries = numEntries(category); |
2021 | for (i = 0; i < entries; ++i) { | 2021 | for (i = 0; i < entries; ++i) { |
2022 | if (searchIn & SEARCH_IN_DESC) { | 2022 | if (searchIn & SEARCH_IN_DESC) { |
2023 | if (!compareString(find.desc, dti.dta[category].d[i].desc, | 2023 | if (!compareString(find.desc, dti.dta[category].d[i].desc, |
2024 | caseSensitive, exactWordMatch)) { | 2024 | caseSensitive, exactWordMatch)) { |
2025 | continue; | 2025 | continue; |
2026 | } | 2026 | } |
2027 | } | 2027 | } |
2028 | if (searchIn & SEARCH_IN_NAME) { | 2028 | if (searchIn & SEARCH_IN_NAME) { |
2029 | if (!compareString(find.name, dti.dta[category].d[i].name, | 2029 | if (!compareString(find.name, dti.dta[category].d[i].name, |
2030 | caseSensitive, exactWordMatch)) { | 2030 | caseSensitive, exactWordMatch)) { |
2031 | continue; | 2031 | continue; |
2032 | } | 2032 | } |
2033 | } | 2033 | } |
2034 | if (searchIn & SEARCH_IN_PW) { | 2034 | if (searchIn & SEARCH_IN_PW) { |
2035 | bool wasLocked = isLocked(category, i); | 2035 | bool wasLocked = isLocked(category, i); |
2036 | getDataChangedLock(); | 2036 | getDataChangedLock(); |
2037 | lockAt(category, i, false); | 2037 | lockAt(category, i, false); |
2038 | if (!compareString(find.pw, dti.dta[category].d[i].pw, | 2038 | if (!compareString(find.pw, dti.dta[category].d[i].pw, |
2039 | caseSensitive, exactWordMatch)) { | 2039 | caseSensitive, exactWordMatch)) { |
2040 | lockAt(category, i, wasLocked); | 2040 | lockAt(category, i, wasLocked); |
2041 | putDataChangedLock(); | 2041 | putDataChangedLock(); |
2042 | continue; | 2042 | continue; |
2043 | } | 2043 | } |
2044 | lockAt(category, i, wasLocked); | 2044 | lockAt(category, i, wasLocked); |
2045 | putDataChangedLock(); | 2045 | putDataChangedLock(); |
2046 | } | 2046 | } |
2047 | if (searchIn & SEARCH_IN_COMMENT) { | 2047 | if (searchIn & SEARCH_IN_COMMENT) { |
2048 | if (!compareString(find.comment, dti.dta[category].d[i].comment, | 2048 | if (!compareString(find.comment, dti.dta[category].d[i].comment, |
2049 | caseSensitive, exactWordMatch)) { | 2049 | caseSensitive, exactWordMatch)) { |
2050 | continue; | 2050 | continue; |
2051 | } | 2051 | } |
2052 | } | 2052 | } |
2053 | if (searchIn & SEARCH_IN_URL) { | 2053 | if (searchIn & SEARCH_IN_URL) { |
2054 | if (!compareString(find.url, dti.dta[category].d[i].url, | 2054 | if (!compareString(find.url, dti.dta[category].d[i].url, |
2055 | caseSensitive, exactWordMatch)) { | 2055 | caseSensitive, exactWordMatch)) { |
2056 | continue; | 2056 | continue; |
2057 | } | 2057 | } |
2058 | } | 2058 | } |
2059 | if (searchIn & SEARCH_IN_LAUNCHER) { | 2059 | if (searchIn & SEARCH_IN_LAUNCHER) { |
2060 | if (!compareString(find.launcher, dti.dta[category].d[i].launcher, | 2060 | if (!compareString(find.launcher, dti.dta[category].d[i].launcher, |
2061 | caseSensitive, exactWordMatch)) { | 2061 | caseSensitive, exactWordMatch)) { |
2062 | continue; | 2062 | continue; |
2063 | } | 2063 | } |
2064 | } | 2064 | } |
2065 | 2065 | ||
2066 | // all selected "searchIn" matched. | 2066 | // all selected "searchIn" matched. |
2067 | foundPositions->push_back(i); | 2067 | foundPositions->push_back(i); |
2068 | if (breakAfterFound) | 2068 | if (breakAfterFound) |
2069 | break; | 2069 | break; |
2070 | } | 2070 | } |
2071 | 2071 | ||
2072 | if (sortByLvp && foundPositions->size() > 1) { | 2072 | if (sortByLvp && foundPositions->size() > 1) { |
2073 | vector< pair<unsigned int /* foundPosition (real doc pos) */, | 2073 | vector< pair<unsigned int /* foundPosition (real doc pos) */, |
2074 | unsigned int /* lvp-pos */> > tmp_vec; | 2074 | unsigned int /* lvp-pos */> > tmp_vec; |
2075 | 2075 | ||
2076 | unsigned int i, items = foundPositions->size(); | 2076 | unsigned int i, items = foundPositions->size(); |
2077 | pair<unsigned int, unsigned int> tmp_pair; | 2077 | pair<unsigned int, unsigned int> tmp_pair; |
2078 | for (i = 0; i < items; ++i) { | 2078 | for (i = 0; i < items; ++i) { |
2079 | tmp_pair.first = (*foundPositions)[i]; | 2079 | tmp_pair.first = (*foundPositions)[i]; |
2080 | tmp_pair.second = dti.dta[category].d[(*foundPositions)[i]].listViewPos; | 2080 | tmp_pair.second = dti.dta[category].d[(*foundPositions)[i]].listViewPos; |
2081 | tmp_vec.push_back(tmp_pair); | 2081 | tmp_vec.push_back(tmp_pair); |
2082 | } | 2082 | } |
2083 | sort(tmp_vec.begin(), tmp_vec.end(), dta_lvp_greater()); | 2083 | sort(tmp_vec.begin(), tmp_vec.end(), dta_lvp_greater()); |
2084 | foundPositions->clear(); | 2084 | foundPositions->clear(); |
2085 | for (i = 0; i < items; ++i) { | 2085 | for (i = 0; i < items; ++i) { |
2086 | foundPositions->push_back(tmp_vec[i].first); | 2086 | foundPositions->push_back(tmp_vec[i].first); |
2087 | } | 2087 | } |
2088 | } | 2088 | } |
2089 | } | 2089 | } |
2090 | 2090 | ||
2091 | void PwMDoc::findEntry(const QString &category, PwMDataItem find, unsigned int searchIn, | 2091 | void PwMDoc::findEntry(const QString &category, PwMDataItem find, unsigned int searchIn, |
2092 | vector<unsigned int> *foundPositions, bool breakAfterFound, | 2092 | vector<unsigned int> *foundPositions, bool breakAfterFound, |
2093 | bool caseSensitive, bool exactWordMatch, bool sortByLvp) | 2093 | bool caseSensitive, bool exactWordMatch, bool sortByLvp) |
2094 | { | 2094 | { |
2095 | PWM_ASSERT(foundPositions); | 2095 | PWM_ASSERT(foundPositions); |
2096 | unsigned int cat = 0; | 2096 | unsigned int cat = 0; |
2097 | 2097 | ||
2098 | if (!findCategory(category, &cat)) { | 2098 | if (!findCategory(category, &cat)) { |
2099 | foundPositions->clear(); | 2099 | foundPositions->clear(); |
2100 | return; | 2100 | return; |
2101 | } | 2101 | } |
2102 | 2102 | ||
2103 | findEntry(cat, find, searchIn, foundPositions, breakAfterFound, | 2103 | findEntry(cat, find, searchIn, foundPositions, breakAfterFound, |
2104 | caseSensitive, exactWordMatch, sortByLvp); | 2104 | caseSensitive, exactWordMatch, sortByLvp); |
2105 | } | 2105 | } |
2106 | 2106 | ||
2107 | bool PwMDoc::compareString(const string &s1, const string &s2, bool caseSensitive, | 2107 | bool PwMDoc::compareString(const string &s1, const string &s2, bool caseSensitive, |
2108 | bool exactWordMatch) | 2108 | bool exactWordMatch) |
2109 | { | 2109 | { |
2110 | QString _s1(s1.c_str()); | 2110 | QString _s1(s1.c_str()); |
2111 | QString _s2(s2.c_str()); | 2111 | QString _s2(s2.c_str()); |
2112 | if (!caseSensitive) { | 2112 | if (!caseSensitive) { |
2113 | _s1 = _s1.lower(); | 2113 | _s1 = _s1.lower(); |
2114 | _s2 = _s2.lower(); | 2114 | _s2 = _s2.lower(); |
2115 | } | 2115 | } |
2116 | if (exactWordMatch ? (_s1 == _s2) : (_s2.find(_s1) != -1)) | 2116 | if (exactWordMatch ? (_s1 == _s2) : (_s2.find(_s1) != -1)) |
2117 | return true; | 2117 | return true; |
2118 | return false; | 2118 | return false; |
2119 | } | 2119 | } |
2120 | 2120 | ||
2121 | bool PwMDoc::findCategory(const QString &name, unsigned int *index) | 2121 | bool PwMDoc::findCategory(const QString &name, unsigned int *index) |
2122 | { | 2122 | { |
2123 | vector<PwMCategoryItem>::iterator i = dti.dta.begin(), | 2123 | vector<PwMCategoryItem>::iterator i = dti.dta.begin(), |
2124 | end = dti.dta.end(); | 2124 | end = dti.dta.end(); |
2125 | while (i != end) { | 2125 | while (i != end) { |
2126 | if ((*i).name == name.latin1()) { | 2126 | if ((*i).name == name.latin1()) { |
2127 | if (index) { | 2127 | if (index) { |
2128 | *index = i - dti.dta.begin(); | 2128 | *index = i - dti.dta.begin(); |
2129 | } | 2129 | } |
2130 | return true; | 2130 | return true; |
2131 | } | 2131 | } |
2132 | ++i; | 2132 | ++i; |
2133 | } | 2133 | } |
2134 | return false; | 2134 | return false; |
2135 | } | 2135 | } |
2136 | 2136 | ||
2137 | bool PwMDoc::renameCategory(const QString &category, const QString &newName) | 2137 | bool PwMDoc::renameCategory(const QString &category, const QString &newName) |
2138 | { | 2138 | { |
2139 | unsigned int cat = 0; | 2139 | unsigned int cat = 0; |
2140 | 2140 | ||
2141 | if (!findCategory(category, &cat)) | 2141 | if (!findCategory(category, &cat)) |
2142 | return false; | 2142 | return false; |
2143 | 2143 | ||
2144 | return renameCategory(cat, newName); | 2144 | return renameCategory(cat, newName); |
2145 | } | 2145 | } |
2146 | 2146 | ||
2147 | bool PwMDoc::renameCategory(unsigned int category, const QString &newName, | 2147 | bool PwMDoc::renameCategory(unsigned int category, const QString &newName, |
2148 | bool dontFlagDirty) | 2148 | bool dontFlagDirty) |
2149 | { | 2149 | { |
2150 | if (category > numCategories() - 1) | 2150 | if (category > numCategories() - 1) |
2151 | return false; | 2151 | return false; |
2152 | 2152 | ||
2153 | dti.dta[category].name = newName.latin1(); | 2153 | dti.dta[category].name = newName.latin1(); |
2154 | if (!dontFlagDirty) | 2154 | if (!dontFlagDirty) |
2155 | flagDirty(); | 2155 | flagDirty(); |
2156 | 2156 | ||
2157 | return true; | 2157 | return true; |
2158 | } | 2158 | } |
2159 | 2159 | ||
2160 | bool PwMDoc::delCategory(const QString &category) | 2160 | bool PwMDoc::delCategory(const QString &category) |
2161 | { | 2161 | { |
2162 | unsigned int cat = 0; | 2162 | unsigned int cat = 0; |
2163 | 2163 | ||
2164 | if (!findCategory(category, &cat)) | 2164 | if (!findCategory(category, &cat)) |
2165 | return false; | 2165 | return false; |
2166 | 2166 | ||
2167 | return delCategory(cat); | 2167 | return delCategory(cat); |
2168 | } | 2168 | } |
2169 | 2169 | ||
2170 | bool PwMDoc::delCategory(unsigned int category, bool dontFlagDirty) | 2170 | bool PwMDoc::delCategory(unsigned int category, bool dontFlagDirty) |
2171 | { | 2171 | { |
2172 | if (category > numCategories() - 1) | 2172 | if (category > numCategories() - 1) |
2173 | return false; | 2173 | return false; |
2174 | 2174 | ||
2175 | // We don't delete it, if it is the last existing | 2175 | // We don't delete it, if it is the last existing |
2176 | // category! Instead we rename it to "Default". | 2176 | // category! Instead we rename it to "Default". |
2177 | if (numCategories() > 1) { | 2177 | if (numCategories() > 1) { |
2178 | dti.dta.erase(dti.dta.begin() + category); | 2178 | dti.dta.erase(dti.dta.begin() + category); |
2179 | } else { | 2179 | } else { |
2180 | renameCategory(category, DEFAULT_CATEGORY, dontFlagDirty); | 2180 | renameCategory(category, DEFAULT_CATEGORY, dontFlagDirty); |
2181 | return true; | 2181 | return true; |
2182 | } | 2182 | } |
2183 | if (!dontFlagDirty) | 2183 | if (!dontFlagDirty) |
2184 | flagDirty(); | 2184 | flagDirty(); |
2185 | 2185 | ||
2186 | return true; | 2186 | return true; |
2187 | } | 2187 | } |
2188 | 2188 | ||
2189 | void PwMDoc::delAllEmptyCat(bool dontFlagDirty) | 2189 | void PwMDoc::delAllEmptyCat(bool dontFlagDirty) |
2190 | { | 2190 | { |
2191 | vector<PwMCategoryItem>::iterator begin = dti.dta.begin(), | 2191 | vector<PwMCategoryItem>::iterator begin = dti.dta.begin(), |
2192 | end = dti.dta.end(), | 2192 | end = dti.dta.end(), |
2193 | i = begin; | 2193 | i = begin; |
2194 | while (i != end) { | 2194 | while (i != end) { |
2195 | if (i->d.empty()) { | 2195 | if (i->d.empty()) { |
2196 | delCategory(begin - i, dontFlagDirty); | 2196 | delCategory(begin - i, dontFlagDirty); |
2197 | } | 2197 | } |
2198 | ++i; | 2198 | ++i; |
2199 | } | 2199 | } |
2200 | } | 2200 | } |
2201 | 2201 | ||
2202 | void PwMDoc::getCategoryList(vector<string> *list) | 2202 | void PwMDoc::getCategoryList(vector<string> *list) |
2203 | { | 2203 | { |
2204 | PWM_ASSERT(list); | 2204 | PWM_ASSERT(list); |
2205 | list->clear(); | 2205 | list->clear(); |
2206 | vector<PwMCategoryItem>::iterator i = dti.dta.begin(), | 2206 | vector<PwMCategoryItem>::iterator i = dti.dta.begin(), |
2207 | end = dti.dta.end(); | 2207 | end = dti.dta.end(); |
2208 | while (i != end) { | 2208 | while (i != end) { |
2209 | list->push_back(i->name); | 2209 | list->push_back(i->name); |
2210 | ++i; | 2210 | ++i; |
2211 | } | 2211 | } |
2212 | } | 2212 | } |
2213 | 2213 | ||
2214 | void PwMDoc::getCategoryList(QStringList *list) | 2214 | void PwMDoc::getCategoryList(QStringList *list) |
2215 | { | 2215 | { |
2216 | PWM_ASSERT(list); | 2216 | PWM_ASSERT(list); |
2217 | list->clear(); | 2217 | list->clear(); |
2218 | vector<PwMCategoryItem>::iterator i = dti.dta.begin(), | 2218 | vector<PwMCategoryItem>::iterator i = dti.dta.begin(), |
2219 | end = dti.dta.end(); | 2219 | end = dti.dta.end(); |
2220 | while (i != end) { | 2220 | while (i != end) { |
2221 | #ifndef PWM_EMBEDDED | 2221 | #ifndef PWM_EMBEDDED |
2222 | list->push_back(i->name.c_str()); | 2222 | list->push_back(i->name.c_str()); |
2223 | #else | 2223 | #else |
2224 | list->append(i->name.c_str()); | 2224 | list->append(i->name.c_str()); |
2225 | #endif | 2225 | #endif |
2226 | ++i; | 2226 | ++i; |
2227 | } | 2227 | } |
2228 | } | 2228 | } |
2229 | 2229 | ||
2230 | void PwMDoc::getEntryList(const QString &category, QStringList *list) | 2230 | void PwMDoc::getEntryList(const QString &category, QStringList *list) |
2231 | { | 2231 | { |
2232 | PWM_ASSERT(list); | 2232 | PWM_ASSERT(list); |
2233 | unsigned int cat = 0; | 2233 | unsigned int cat = 0; |
2234 | if (!findCategory(category, &cat)) { | 2234 | if (!findCategory(category, &cat)) { |
2235 | list->clear(); | 2235 | list->clear(); |
2236 | return; | 2236 | return; |
2237 | } | 2237 | } |
2238 | getEntryList(cat, list); | 2238 | getEntryList(cat, list); |
2239 | } | 2239 | } |
2240 | 2240 | ||
2241 | void PwMDoc::getEntryList(const QString &category, vector<string> *list) | 2241 | void PwMDoc::getEntryList(const QString &category, vector<string> *list) |
2242 | { | 2242 | { |
2243 | PWM_ASSERT(list); | 2243 | PWM_ASSERT(list); |
2244 | unsigned int cat = 0; | 2244 | unsigned int cat = 0; |
2245 | if (!findCategory(category, &cat)) { | 2245 | if (!findCategory(category, &cat)) { |
2246 | list->clear(); | 2246 | list->clear(); |
2247 | return; | 2247 | return; |
2248 | } | 2248 | } |
2249 | getEntryList(cat, list); | 2249 | getEntryList(cat, list); |
2250 | } | 2250 | } |
2251 | 2251 | ||
2252 | void PwMDoc::getEntryList(unsigned int category, vector<string> *list) | 2252 | void PwMDoc::getEntryList(unsigned int category, vector<string> *list) |
2253 | { | 2253 | { |
2254 | PWM_ASSERT(list); | 2254 | PWM_ASSERT(list); |
2255 | list->clear(); | 2255 | list->clear(); |
2256 | vector<PwMDataItem>::iterator begin = dti.dta[category].d.begin(), | 2256 | vector<PwMDataItem>::iterator begin = dti.dta[category].d.begin(), |
2257 | end = dti.dta[category].d.end(), | 2257 | end = dti.dta[category].d.end(), |
2258 | i = begin; | 2258 | i = begin; |
2259 | while (i != end) { | 2259 | while (i != end) { |
2260 | list->push_back(i->desc); | 2260 | list->push_back(i->desc); |
2261 | ++i; | 2261 | ++i; |
2262 | } | 2262 | } |
2263 | } | 2263 | } |
2264 | 2264 | ||
2265 | void PwMDoc::getEntryList(unsigned int category, QStringList *list) | 2265 | void PwMDoc::getEntryList(unsigned int category, QStringList *list) |
2266 | { | 2266 | { |
2267 | PWM_ASSERT(list); | 2267 | PWM_ASSERT(list); |
2268 | list->clear(); | 2268 | list->clear(); |
2269 | vector<PwMDataItem>::iterator begin = dti.dta[category].d.begin(), | 2269 | vector<PwMDataItem>::iterator begin = dti.dta[category].d.begin(), |
2270 | end = dti.dta[category].d.end(), | 2270 | end = dti.dta[category].d.end(), |
2271 | i = begin; | 2271 | i = begin; |
2272 | while (i != end) { | 2272 | while (i != end) { |
2273 | #ifndef PWM_EMBEDDED | 2273 | #ifndef PWM_EMBEDDED |
2274 | list->push_back(i->desc.c_str()); | 2274 | list->push_back(i->desc.c_str()); |
2275 | #else | 2275 | #else |
2276 | list->append(i->desc.c_str()); | 2276 | list->append(i->desc.c_str()); |
2277 | #endif | 2277 | #endif |
2278 | ++i; | 2278 | ++i; |
2279 | } | 2279 | } |
2280 | } | 2280 | } |
2281 | 2281 | ||
2282 | bool PwMDoc::execLauncher(const QString &category, unsigned int entryIndex) | 2282 | bool PwMDoc::execLauncher(const QString &category, unsigned int entryIndex) |
2283 | { | 2283 | { |
2284 | unsigned int cat = 0; | 2284 | unsigned int cat = 0; |
2285 | 2285 | ||
2286 | if (!findCategory(category, &cat)) | 2286 | if (!findCategory(category, &cat)) |
2287 | return false; | 2287 | return false; |
2288 | 2288 | ||
2289 | return execLauncher(cat, entryIndex); | 2289 | return execLauncher(cat, entryIndex); |
2290 | } | 2290 | } |
2291 | 2291 | ||
2292 | bool PwMDoc::execLauncher(unsigned int category, unsigned int entryIndex) | 2292 | bool PwMDoc::execLauncher(unsigned int category, unsigned int entryIndex) |
2293 | { | 2293 | { |
2294 | #ifndef _WIN32_ | 2294 | #ifndef _WIN32_ |
2295 | if (geteuid() == 0) { | 2295 | if (geteuid() == 0) { |
2296 | rootAlertMsgBox(); | 2296 | rootAlertMsgBox(); |
2297 | return false; | 2297 | return false; |
2298 | } | 2298 | } |
2299 | #endif | 2299 | #endif |
2300 | QString command(dti.dta[category].d[entryIndex].launcher.c_str()); | 2300 | QString command(dti.dta[category].d[entryIndex].launcher.c_str()); |
2301 | bool wasLocked = isLocked(category, entryIndex); | 2301 | bool wasLocked = isLocked(category, entryIndex); |
2302 | 2302 | ||
2303 | if (command.find("$p") != -1) { | 2303 | if (command.find("$p") != -1) { |
2304 | /* the user requested the password to be included | 2304 | /* the user requested the password to be included |
2305 | * into the command. We have to ask for the password, | 2305 | * into the command. We have to ask for the password, |
2306 | * if it's locked. We do that by unlocking the entry | 2306 | * if it's locked. We do that by unlocking the entry |
2307 | */ | 2307 | */ |
2308 | if (!lockAt(category, entryIndex, false)) | 2308 | if (!lockAt(category, entryIndex, false)) |
2309 | return false; | 2309 | return false; |
2310 | } | 2310 | } |
2311 | #ifndef PWM_EMBEDDED | 2311 | #ifndef PWM_EMBEDDED |
2312 | command.replace("$d", dti.dta[category].d[entryIndex].desc.c_str()); | 2312 | command.replace("$d", dti.dta[category].d[entryIndex].desc.c_str()); |
2313 | command.replace("$n", dti.dta[category].d[entryIndex].name.c_str()); | 2313 | command.replace("$n", dti.dta[category].d[entryIndex].name.c_str()); |
2314 | command.replace("$p", dti.dta[category].d[entryIndex].pw.c_str()); | 2314 | command.replace("$p", dti.dta[category].d[entryIndex].pw.c_str()); |
2315 | command.replace("$u", dti.dta[category].d[entryIndex].url.c_str()); | 2315 | command.replace("$u", dti.dta[category].d[entryIndex].url.c_str()); |
2316 | command.replace("$c", dti.dta[category].d[entryIndex].comment.c_str()); | 2316 | command.replace("$c", dti.dta[category].d[entryIndex].comment.c_str()); |
2317 | #else | 2317 | #else |
2318 | command.replace(QRegExp("$d"), dti.dta[category].d[entryIndex].desc.c_str()); | 2318 | command.replace(QRegExp("$d"), dti.dta[category].d[entryIndex].desc.c_str()); |
2319 | command.replace(QRegExp("$n"), dti.dta[category].d[entryIndex].name.c_str()); | 2319 | command.replace(QRegExp("$n"), dti.dta[category].d[entryIndex].name.c_str()); |
2320 | command.replace(QRegExp("$p"), dti.dta[category].d[entryIndex].pw.c_str()); | 2320 | command.replace(QRegExp("$p"), dti.dta[category].d[entryIndex].pw.c_str()); |
2321 | command.replace(QRegExp("$u"), dti.dta[category].d[entryIndex].url.c_str()); | 2321 | command.replace(QRegExp("$u"), dti.dta[category].d[entryIndex].url.c_str()); |
2322 | command.replace(QRegExp("$c"), dti.dta[category].d[entryIndex].comment.c_str()); | 2322 | command.replace(QRegExp("$c"), dti.dta[category].d[entryIndex].comment.c_str()); |
2323 | #endif | 2323 | #endif |
2324 | command.append(" &"); | 2324 | command.append(" &"); |
2325 | 2325 | ||
2326 | QString customXterm(conf()->confGlobXtermCommand()); | 2326 | QString customXterm(conf()->confGlobXtermCommand()); |
2327 | if (!customXterm.isEmpty()) | 2327 | if (!customXterm.isEmpty()) |
2328 | command = customXterm + " " + command; | 2328 | command = customXterm + " " + command; |
2329 | 2329 | ||
2330 | system(command.latin1()); | 2330 | system(command.latin1()); |
2331 | 2331 | ||
2332 | lockAt(category, entryIndex, wasLocked); | 2332 | lockAt(category, entryIndex, wasLocked); |
2333 | return true; | 2333 | return true; |
2334 | } | 2334 | } |
2335 | 2335 | ||
2336 | bool PwMDoc::goToURL(const QString &category, unsigned int entryIndex) | 2336 | bool PwMDoc::goToURL(const QString &category, unsigned int entryIndex) |
2337 | { | 2337 | { |
2338 | unsigned int cat = 0; | 2338 | unsigned int cat = 0; |
2339 | 2339 | ||
2340 | if (!findCategory(category, &cat)) | 2340 | if (!findCategory(category, &cat)) |
2341 | return false; | 2341 | return false; |
2342 | 2342 | ||
2343 | return goToURL(cat, entryIndex); | 2343 | return goToURL(cat, entryIndex); |
2344 | } | 2344 | } |
2345 | 2345 | ||
2346 | bool PwMDoc::goToURL(unsigned int category, unsigned int entryIndex) | 2346 | bool PwMDoc::goToURL(unsigned int category, unsigned int entryIndex) |
2347 | { | 2347 | { |
2348 | #ifndef _WIN32_ | 2348 | #ifndef _WIN32_ |
2349 | if (geteuid() == 0) { | 2349 | if (geteuid() == 0) { |
2350 | rootAlertMsgBox(); | 2350 | rootAlertMsgBox(); |
2351 | return false; | 2351 | return false; |
2352 | } | 2352 | } |
2353 | #endif | 2353 | #endif |
2354 | QString url(dti.dta[category].d[entryIndex].url.c_str()); | 2354 | QString url(dti.dta[category].d[entryIndex].url.c_str()); |
2355 | if (url.isEmpty()) | 2355 | if (url.isEmpty()) |
2356 | return false; | 2356 | return false; |
2357 | 2357 | ||
2358 | QString customBrowser(conf()->confGlobBrowserCommand()); | 2358 | QString customBrowser(conf()->confGlobBrowserCommand()); |
2359 | if (!customBrowser.isEmpty()) { | 2359 | if (!customBrowser.isEmpty()) { |
2360 | browserProc.clearArguments(); | 2360 | browserProc.clearArguments(); |
2361 | browserProc << customBrowser << url; | 2361 | browserProc << customBrowser << url; |
2362 | if (browserProc.start(KProcess::DontCare)) | 2362 | if (browserProc.start(KProcess::DontCare)) |
2363 | return true; | 2363 | return true; |
2364 | } | 2364 | } |
2365 | 2365 | ||
2366 | browserProc.clearArguments(); | 2366 | browserProc.clearArguments(); |
2367 | browserProc << "konqueror" << url; | 2367 | browserProc << "konqueror" << url; |
2368 | if (browserProc.start(KProcess::DontCare)) | 2368 | if (browserProc.start(KProcess::DontCare)) |
2369 | return true; | 2369 | return true; |
2370 | 2370 | ||
2371 | browserProc.clearArguments(); | 2371 | browserProc.clearArguments(); |
2372 | browserProc << "mozilla" << url; | 2372 | browserProc << "mozilla" << url; |
2373 | if (browserProc.start(KProcess::DontCare)) | 2373 | if (browserProc.start(KProcess::DontCare)) |
2374 | return true; | 2374 | return true; |
2375 | 2375 | ||
2376 | browserProc.clearArguments(); | 2376 | browserProc.clearArguments(); |
2377 | browserProc << "opera" << url; | 2377 | browserProc << "opera" << url; |
2378 | if (browserProc.start(KProcess::DontCare)) | 2378 | if (browserProc.start(KProcess::DontCare)) |
2379 | return true; | 2379 | return true; |
2380 | return false; | 2380 | return false; |
2381 | } | 2381 | } |
2382 | 2382 | ||
2383 | PwMerror PwMDoc::exportToText(const QString *file) | 2383 | PwMerror PwMDoc::exportToText(const QString *file) |
2384 | { | 2384 | { |
2385 | PWM_ASSERT(file); | 2385 | PWM_ASSERT(file); |
2386 | if (QFile::exists(*file)) { | 2386 | if (QFile::exists(*file)) { |
2387 | if (!QFile::remove(*file)) | 2387 | if (!QFile::remove(*file)) |
2388 | return e_accessFile; | 2388 | return e_accessFile; |
2389 | } | 2389 | } |
2390 | QFile f(*file); | 2390 | QFile f(*file); |
2391 | if (!f.open(IO_ReadWrite)) | 2391 | if (!f.open(IO_ReadWrite)) |
2392 | return e_openFile; | 2392 | return e_openFile; |
2393 | 2393 | ||
2394 | if (!unlockAll_tempoary()) { | 2394 | if (!unlockAll_tempoary()) { |
2395 | f.close(); | 2395 | f.close(); |
2396 | return e_lock; | 2396 | return e_lock; |
2397 | } | 2397 | } |
2398 | 2398 | ||
2399 | // write header | 2399 | // write header |
2400 | string header = i18n("Password table generated by\nPwM v").latin1(); | 2400 | string header = i18n("Password table generated by\nPwM v").latin1(); |
2401 | header += PACKAGE_VER; | 2401 | header += PACKAGE_VER; |
2402 | header += i18n("\non ").latin1(); | 2402 | header += i18n("\non ").latin1(); |
2403 | QDate currDate = QDate::currentDate(); | 2403 | QDate currDate = QDate::currentDate(); |
2404 | QTime currTime = QTime::currentTime(); | 2404 | QTime currTime = QTime::currentTime(); |
2405 | 2405 | ||
2406 | #ifndef PWM_EMBEDDED | 2406 | #ifndef PWM_EMBEDDED |
2407 | header += currDate.toString("ddd MMMM d ").latin1(); | 2407 | header += currDate.toString("ddd MMMM d ").latin1(); |
2408 | header += currTime.toString("hh:mm:ss ").latin1(); | 2408 | header += currTime.toString("hh:mm:ss ").latin1(); |
2409 | #else | 2409 | #else |
2410 | QString dfs = KGlobal::locale()->dateFormatShort(); | 2410 | QString dfs = KGlobal::locale()->dateFormatShort(); |
2411 | bool ampm = KGlobal::locale()->use12Clock(); | 2411 | bool ampm = KGlobal::locale()->use12Clock(); |
2412 | KGlobal::locale()->setDateFormatShort("%A %B %d"); | 2412 | KGlobal::locale()->setDateFormatShort("%A %B %d"); |
2413 | KGlobal::locale()->setHore24Format(true); | 2413 | KGlobal::locale()->setHore24Format(true); |
2414 | 2414 | ||
2415 | header += KGlobal::locale()->formatDate(currDate, true, KLocale::Userdefined).latin1(); | 2415 | header += KGlobal::locale()->formatDate(currDate, true, KLocale::Userdefined).latin1(); |
2416 | header += KGlobal::locale()->formatTime(currTime, true).latin1(); | 2416 | header += KGlobal::locale()->formatTime(currTime, true).latin1(); |
2417 | KGlobal::locale()->setDateFormatShort(dfs); | 2417 | KGlobal::locale()->setDateFormatShort(dfs); |
2418 | KGlobal::locale()->setHore24Format(!ampm); | 2418 | KGlobal::locale()->setHore24Format(!ampm); |
2419 | 2419 | ||
2420 | #endif | 2420 | #endif |
2421 | header += tostr(currDate.year()); | 2421 | header += tostr(currDate.year()); |
2422 | header += "\n==============================\n\n"; | 2422 | header += "\n==============================\n\n"; |
2423 | 2423 | ||
2424 | 2424 | ||
2425 | #ifndef PWM_EMBEDDED | 2425 | #ifndef PWM_EMBEDDED |
2426 | if (f.writeBlock(header.c_str(), header.length()) != (Q_LONG)header.length()) { | 2426 | if (f.writeBlock(header.c_str(), header.length()) != (Q_LONG)header.length()) { |
2427 | unlockAll_tempoary(true); | 2427 | unlockAll_tempoary(true); |
2428 | f.close(); | 2428 | f.close(); |
2429 | return e_writeFile; | 2429 | return e_writeFile; |
2430 | } | 2430 | } |
2431 | #else | 2431 | #else |
2432 | if (f.writeBlock(header.c_str(), header.length()) != (long)header.length()) { | 2432 | if (f.writeBlock(header.c_str(), header.length()) != (long)header.length()) { |
2433 | unlockAll_tempoary(true); | 2433 | unlockAll_tempoary(true); |
2434 | f.close(); | 2434 | f.close(); |
2435 | return e_writeFile; | 2435 | return e_writeFile; |
2436 | } | 2436 | } |
2437 | #endif | 2437 | #endif |
2438 | unsigned int i, numCat = numCategories(); | 2438 | unsigned int i, numCat = numCategories(); |
2439 | unsigned int j, numEnt; | 2439 | unsigned int j, numEnt; |
2440 | string exp; | 2440 | string exp; |
2441 | for (i = 0; i < numCat; ++i) { | 2441 | for (i = 0; i < numCat; ++i) { |
2442 | numEnt = numEntries(i); | 2442 | numEnt = numEntries(i); |
2443 | 2443 | ||
2444 | exp = "\n== Category: "; | 2444 | exp = "\n== Category: "; |
2445 | exp += dti.dta[i].name; | 2445 | exp += dti.dta[i].name; |
2446 | exp += " ==\n"; | 2446 | exp += " ==\n"; |
2447 | #ifndef PWM_EMBEDDED | 2447 | #ifndef PWM_EMBEDDED |
2448 | if (f.writeBlock(exp.c_str(), exp.length()) != (Q_LONG)exp.length()) { | 2448 | if (f.writeBlock(exp.c_str(), exp.length()) != (Q_LONG)exp.length()) { |
2449 | unlockAll_tempoary(true); | 2449 | unlockAll_tempoary(true); |
2450 | f.close(); | 2450 | f.close(); |
2451 | return e_writeFile; | 2451 | return e_writeFile; |
2452 | } | 2452 | } |
2453 | #else | 2453 | #else |
2454 | if (f.writeBlock(exp.c_str(), exp.length()) != (long)exp.length()) { | 2454 | if (f.writeBlock(exp.c_str(), exp.length()) != (long)exp.length()) { |
2455 | unlockAll_tempoary(true); | 2455 | unlockAll_tempoary(true); |
2456 | f.close(); | 2456 | f.close(); |
2457 | return e_writeFile; | 2457 | return e_writeFile; |
2458 | } | 2458 | } |
2459 | #endif | 2459 | #endif |
2460 | for (j = 0; j < numEnt; ++j) { | 2460 | for (j = 0; j < numEnt; ++j) { |
2461 | exp = "\n-- "; | 2461 | exp = "\n-- "; |
2462 | exp += dti.dta[i].d[j].desc; | 2462 | exp += dti.dta[i].d[j].desc; |
2463 | exp += " --\n"; | 2463 | exp += " --\n"; |
2464 | 2464 | ||
2465 | exp += i18n("Username: ").latin1(); | 2465 | exp += i18n("Username: ").latin1(); |
2466 | exp += dti.dta[i].d[j].name; | 2466 | exp += dti.dta[i].d[j].name; |
2467 | exp += "\n"; | 2467 | exp += "\n"; |
2468 | 2468 | ||
2469 | exp += i18n("Password: ").latin1(); | 2469 | exp += i18n("Password: ").latin1(); |
2470 | exp += dti.dta[i].d[j].pw; | 2470 | exp += dti.dta[i].d[j].pw; |
2471 | exp += "\n"; | 2471 | exp += "\n"; |
2472 | 2472 | ||
2473 | exp += i18n("Comment: ").latin1(); | 2473 | exp += i18n("Comment: ").latin1(); |
2474 | exp += dti.dta[i].d[j].comment; | 2474 | exp += dti.dta[i].d[j].comment; |
2475 | exp += "\n"; | 2475 | exp += "\n"; |
2476 | 2476 | ||
2477 | exp += i18n("URL: ").latin1(); | 2477 | exp += i18n("URL: ").latin1(); |
2478 | exp += dti.dta[i].d[j].url; | 2478 | exp += dti.dta[i].d[j].url; |
2479 | exp += "\n"; | 2479 | exp += "\n"; |
2480 | 2480 | ||
2481 | exp += i18n("Launcher: ").latin1(); | 2481 | exp += i18n("Launcher: ").latin1(); |
2482 | exp += dti.dta[i].d[j].launcher; | 2482 | exp += dti.dta[i].d[j].launcher; |
2483 | exp += "\n"; | 2483 | exp += "\n"; |
2484 | 2484 | ||
2485 | #ifndef PWM_EMBEDDED | 2485 | #ifndef PWM_EMBEDDED |
2486 | if (f.writeBlock(exp.c_str(), exp.length()) != (Q_LONG)exp.length()) { | 2486 | if (f.writeBlock(exp.c_str(), exp.length()) != (Q_LONG)exp.length()) { |
2487 | unlockAll_tempoary(true); | 2487 | unlockAll_tempoary(true); |
2488 | f.close(); | 2488 | f.close(); |
2489 | return e_writeFile; | 2489 | return e_writeFile; |
2490 | } | 2490 | } |
2491 | #else | 2491 | #else |
2492 | if (f.writeBlock(exp.c_str(), exp.length()) != (long)exp.length()) { | 2492 | if (f.writeBlock(exp.c_str(), exp.length()) != (long)exp.length()) { |
2493 | unlockAll_tempoary(true); | 2493 | unlockAll_tempoary(true); |
2494 | f.close(); | 2494 | f.close(); |
2495 | return e_writeFile; | 2495 | return e_writeFile; |
2496 | } | 2496 | } |
2497 | #endif | 2497 | #endif |
2498 | } | 2498 | } |
2499 | } | 2499 | } |
2500 | unlockAll_tempoary(true); | 2500 | unlockAll_tempoary(true); |
2501 | f.close(); | 2501 | f.close(); |
2502 | 2502 | ||
2503 | return e_success; | 2503 | return e_success; |
2504 | } | 2504 | } |
2505 | 2505 | ||
2506 | PwMerror PwMDoc::importFromText(const QString *file, int format) | 2506 | PwMerror PwMDoc::importFromText(const QString *file, int format) |
2507 | { | 2507 | { |
2508 | PWM_ASSERT(file); | 2508 | PWM_ASSERT(file); |
2509 | if (format == 0) | 2509 | if (format == 0) |
2510 | return importText_PwM(file); | 2510 | return importText_PwM(file); |
2511 | else if (format == -1) { | 2511 | else if (format == -1) { |
2512 | // probe for all formats | 2512 | // probe for all formats |
2513 | if (importText_PwM(file) == e_success) | 2513 | if (importText_PwM(file) == e_success) |
2514 | return e_success; | 2514 | return e_success; |
2515 | dti.clear(); | 2515 | dti.clear(); |
2516 | emitDataChanged(this); | 2516 | emitDataChanged(this); |
2517 | // add next format here... | 2517 | // add next format here... |
2518 | return e_fileFormat; | 2518 | return e_fileFormat; |
2519 | } | 2519 | } |
2520 | return e_invalidArg; | 2520 | return e_invalidArg; |
2521 | } | 2521 | } |
2522 | 2522 | ||
2523 | PwMerror PwMDoc::importText_PwM(const QString *file) | 2523 | PwMerror PwMDoc::importText_PwM(const QString *file) |
2524 | { | 2524 | { |
2525 | #ifndef PWM_EMBEDDED | 2525 | #ifndef PWM_EMBEDDED |
2526 | PWM_ASSERT(file); | 2526 | PWM_ASSERT(file); |
2527 | FILE *f; | 2527 | FILE *f; |
2528 | int tmp; | 2528 | int tmp; |
2529 | ssize_t ret; | 2529 | ssize_t ret; |
2530 | string curCat; | 2530 | string curCat; |
2531 | unsigned int entriesRead = 0; | 2531 | unsigned int entriesRead = 0; |
2532 | PwMDataItem currItem; | 2532 | PwMDataItem currItem; |
2533 | f = fopen(file->latin1(), "r"); | 2533 | f = fopen(file->latin1(), "r"); |
2534 | if (!f) | 2534 | if (!f) |
2535 | return e_openFile; | 2535 | return e_openFile; |
2536 | size_t ch_tmp_size = 1024; | 2536 | size_t ch_tmp_size = 1024; |
2537 | char *ch_tmp = (char*)malloc(ch_tmp_size); | 2537 | char *ch_tmp = (char*)malloc(ch_tmp_size); |
2538 | if (!ch_tmp) { | 2538 | if (!ch_tmp) { |
2539 | fclose(f); | 2539 | fclose(f); |
2540 | return e_outOfMem; | 2540 | return e_outOfMem; |
2541 | } | 2541 | } |
2542 | 2542 | ||
2543 | // - check header | 2543 | // - check header |
2544 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) // skip first line. | 2544 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) // skip first line. |
2545 | goto formatError; | 2545 | goto formatError; |
2546 | // check version-string and return version in "ch_tmp". | 2546 | // check version-string and return version in "ch_tmp". |
2547 | if (fscanf(f, "PwM v%s", ch_tmp) != 1) { | 2547 | if (fscanf(f, "PwM v%s", ch_tmp) != 1) { |
2548 | // header not recognized as PwM generated header | 2548 | // header not recognized as PwM generated header |
2549 | goto formatError; | 2549 | goto formatError; |
2550 | } | 2550 | } |
2551 | // set filepointer behind version-string-line previously checked | 2551 | // set filepointer behind version-string-line previously checked |
2552 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) | 2552 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) |
2553 | goto formatError; | 2553 | goto formatError; |
2554 | // skip next line containing the build-date | 2554 | // skip next line containing the build-date |
2555 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) | 2555 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) |
2556 | goto formatError; | 2556 | goto formatError; |
2557 | // read header termination line | 2557 | // read header termination line |
2558 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) | 2558 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) |
2559 | goto formatError; | 2559 | goto formatError; |
2560 | if (strcmp(ch_tmp, "==============================\n")) | 2560 | if (strcmp(ch_tmp, "==============================\n")) |
2561 | goto formatError; | 2561 | goto formatError; |
2562 | 2562 | ||
2563 | // - read entries | 2563 | // - read entries |
2564 | do { | 2564 | do { |
2565 | // find beginning of next category | 2565 | // find beginning of next category |
2566 | do { | 2566 | do { |
2567 | tmp = fgetc(f); | 2567 | tmp = fgetc(f); |
2568 | } while (tmp == '\n' && tmp != EOF); | 2568 | } while (tmp == '\n' && tmp != EOF); |
2569 | if (tmp == EOF) | 2569 | if (tmp == EOF) |
2570 | break; | 2570 | break; |
2571 | 2571 | ||
2572 | // decrement filepos by one | 2572 | // decrement filepos by one |
2573 | fseek(f, -1, SEEK_CUR); | 2573 | fseek(f, -1, SEEK_CUR); |
2574 | // read cat-name | 2574 | // read cat-name |
2575 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) | 2575 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) |
2576 | goto formatError; | 2576 | goto formatError; |
2577 | // check cat-name format | 2577 | // check cat-name format |
2578 | if (memcmp(ch_tmp, "== Category: ", 13) != 0) | 2578 | if (memcmp(ch_tmp, "== Category: ", 13) != 0) |
2579 | goto formatError; | 2579 | goto formatError; |
2580 | if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " ==", 3) != 0) | 2580 | if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " ==", 3) != 0) |
2581 | goto formatError; | 2581 | goto formatError; |
2582 | // copy cat-name | 2582 | // copy cat-name |
2583 | curCat.assign(ch_tmp + 13, strlen(ch_tmp) - 1 - 16); | 2583 | curCat.assign(ch_tmp + 13, strlen(ch_tmp) - 1 - 16); |
2584 | 2584 | ||
2585 | do { | 2585 | do { |
2586 | // find beginning of next entry | 2586 | // find beginning of next entry |
2587 | do { | 2587 | do { |
2588 | tmp = fgetc(f); | 2588 | tmp = fgetc(f); |
2589 | } while (tmp == '\n' && tmp != EOF && tmp != '='); | 2589 | } while (tmp == '\n' && tmp != EOF && tmp != '='); |
2590 | if (tmp == EOF) | 2590 | if (tmp == EOF) |
2591 | break; | 2591 | break; |
2592 | if (tmp == '=') { | 2592 | if (tmp == '=') { |
2593 | fseek(f, -1, SEEK_CUR); | 2593 | fseek(f, -1, SEEK_CUR); |
2594 | break; | 2594 | break; |
2595 | } | 2595 | } |
2596 | // decrement filepos by one | 2596 | // decrement filepos by one |
2597 | fseek(f, -1, SEEK_CUR); | 2597 | fseek(f, -1, SEEK_CUR); |
2598 | // read desc-line | 2598 | // read desc-line |
2599 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) | 2599 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) |
2600 | goto formatError; | 2600 | goto formatError; |
2601 | // check desc-line format | 2601 | // check desc-line format |
2602 | if (memcmp(ch_tmp, "-- ", 3) != 0) | 2602 | if (memcmp(ch_tmp, "-- ", 3) != 0) |
2603 | goto formatError; | 2603 | goto formatError; |
2604 | if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " --", 3) != 0) | 2604 | if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " --", 3) != 0) |
2605 | goto formatError; | 2605 | goto formatError; |
2606 | // add desc-line | 2606 | // add desc-line |
2607 | currItem.desc.assign(ch_tmp + 3, strlen(ch_tmp) - 1 - 6); | 2607 | currItem.desc.assign(ch_tmp + 3, strlen(ch_tmp) - 1 - 6); |
2608 | 2608 | ||
2609 | // read username-line | 2609 | // read username-line |
2610 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) | 2610 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) |
2611 | goto formatError; | 2611 | goto formatError; |
2612 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.name)) | 2612 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.name)) |
2613 | goto formatError; | 2613 | goto formatError; |
2614 | 2614 | ||
2615 | // read pw-line | 2615 | // read pw-line |
2616 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) | 2616 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) |
2617 | goto formatError; | 2617 | goto formatError; |
2618 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.pw)) | 2618 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.pw)) |
2619 | goto formatError; | 2619 | goto formatError; |
2620 | 2620 | ||
2621 | // read comment-line | 2621 | // read comment-line |
2622 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) | 2622 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) |
2623 | goto formatError; | 2623 | goto formatError; |
2624 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.comment)) | 2624 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.comment)) |
2625 | goto formatError; | 2625 | goto formatError; |
2626 | 2626 | ||
2627 | // read URL-line | 2627 | // read URL-line |
2628 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) | 2628 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) |
2629 | goto formatError; | 2629 | goto formatError; |
2630 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.url)) | 2630 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.url)) |
2631 | goto formatError; | 2631 | goto formatError; |
2632 | 2632 | ||
2633 | // read launcher-line | 2633 | // read launcher-line |
2634 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) | 2634 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) |
2635 | goto formatError; | 2635 | goto formatError; |
2636 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.launcher)) | 2636 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.launcher)) |
2637 | goto formatError; | 2637 | goto formatError; |
2638 | 2638 | ||
2639 | currItem.lockStat = true; | 2639 | currItem.lockStat = true; |
2640 | currItem.listViewPos = -1; | 2640 | currItem.listViewPos = -1; |
2641 | addEntry(curCat.c_str(), &currItem, true); | 2641 | addEntry(curCat.c_str(), &currItem, true); |
2642 | ++entriesRead; | 2642 | ++entriesRead; |
2643 | } while (1); | 2643 | } while (1); |
2644 | } while (1); | 2644 | } while (1); |
2645 | if (!entriesRead) | 2645 | if (!entriesRead) |
2646 | goto formatError; | 2646 | goto formatError; |
2647 | 2647 | ||
2648 | free(ch_tmp); | 2648 | free(ch_tmp); |
2649 | fclose(f); | 2649 | fclose(f); |
2650 | flagDirty(); | 2650 | flagDirty(); |
2651 | return e_success; | 2651 | return e_success; |
2652 | 2652 | ||
2653 | formatError: | 2653 | formatError: |
2654 | free(ch_tmp); | 2654 | free(ch_tmp); |
2655 | fclose(f); | 2655 | fclose(f); |
2656 | return e_fileFormat; | 2656 | return e_fileFormat; |
2657 | #else | 2657 | #else |
2658 | PWM_ASSERT(file); | 2658 | PWM_ASSERT(file); |
2659 | QFile f(file->latin1()); | 2659 | QFile f(file->latin1()); |
2660 | int tmp; | 2660 | int tmp; |
2661 | ssize_t ret; | 2661 | ssize_t ret; |
2662 | string curCat; | 2662 | string curCat; |
2663 | unsigned int entriesRead = 0; | 2663 | unsigned int entriesRead = 0; |
2664 | PwMDataItem currItem; | 2664 | PwMDataItem currItem; |
2665 | bool res = f.open(IO_ReadOnly); | 2665 | bool res = f.open(IO_ReadOnly); |
2666 | if (res == false) | 2666 | if (res == false) |
2667 | return e_openFile; | 2667 | return e_openFile; |
2668 | 2668 | ||
2669 | unsigned int ch_tmp_size = 1024; | 2669 | unsigned int ch_tmp_size = 1024; |
2670 | char *ch_tmp = (char*)malloc(ch_tmp_size); | 2670 | char *ch_tmp = (char*)malloc(ch_tmp_size); |
2671 | if (!ch_tmp) { | 2671 | if (!ch_tmp) { |
2672 | f.close(); | 2672 | f.close(); |
2673 | return e_outOfMem; | 2673 | return e_outOfMem; |
2674 | } | 2674 | } |
2675 | 2675 | ||
2676 | // - check header | 2676 | // - check header |
2677 | if (f.readLine(ch_tmp, ch_tmp_size) == -1) // skip first line. | 2677 | if (f.readLine(ch_tmp, ch_tmp_size) == -1) // skip first line. |
2678 | goto formatError; | 2678 | goto formatError; |
2679 | 2679 | ||
2680 | //US read fileversion first, then check if ok. | 2680 | //US read fileversion first, then check if ok. |
2681 | if (f.readLine(ch_tmp, ch_tmp_size) == -1) | 2681 | if (f.readLine(ch_tmp, ch_tmp_size) == -1) |
2682 | goto formatError; | 2682 | goto formatError; |
2683 | 2683 | ||
2684 | // check version-string and return version in "ch_tmp". | 2684 | // check version-string and return version in "ch_tmp". |
2685 | //US if (fscanf(f, "PwM v%s", ch_tmp) != 1) { | 2685 | //US if (fscanf(f, "PwM v%s", ch_tmp) != 1) { |
2686 | //US // header not recognized as PwM generated header | 2686 | //US // header not recognized as PwM generated header |
2687 | //US goto formatError; | 2687 | //US goto formatError; |
2688 | //US} | 2688 | //US} |
2689 | //US set filepointer behind version-string-line previously checked | 2689 | //US set filepointer behind version-string-line previously checked |
2690 | //US if (f.readLine(ch_tmp, ch_tmp_size) == -1) | 2690 | //US if (f.readLine(ch_tmp, ch_tmp_size) == -1) |
2691 | //US goto formatError; | 2691 | //US goto formatError; |
2692 | // skip next line containing the build-date | 2692 | // skip next line containing the build-date |
2693 | if (f.readLine(ch_tmp, ch_tmp_size) == -1) | 2693 | if (f.readLine(ch_tmp, ch_tmp_size) == -1) |
2694 | goto formatError; | 2694 | goto formatError; |
2695 | // read header termination line | 2695 | // read header termination line |
2696 | if (f.readLine(ch_tmp, ch_tmp_size) == -1) | 2696 | if (f.readLine(ch_tmp, ch_tmp_size) == -1) |
2697 | goto formatError; | 2697 | goto formatError; |
2698 | if (strcmp(ch_tmp, "==============================\n")) | 2698 | if (strcmp(ch_tmp, "==============================\n")) |
2699 | goto formatError; | 2699 | goto formatError; |
2700 | 2700 | ||
2701 | // - read entries | 2701 | // - read entries |
2702 | do { | 2702 | do { |
2703 | // find beginning of next category | 2703 | // find beginning of next category |
2704 | do { | 2704 | do { |
2705 | tmp = f.getch(); | 2705 | tmp = f.getch(); |
2706 | } while (tmp == '\n' && tmp != EOF); | 2706 | } while (tmp == '\n' && tmp != EOF); |
2707 | if (tmp == EOF) | 2707 | if (tmp == EOF) |
2708 | break; | 2708 | break; |
2709 | 2709 | ||
2710 | // decrement filepos by one | 2710 | // decrement filepos by one |
2711 | f.at(f.at()-1); | 2711 | f.at(f.at()-1); |
2712 | // read cat-name | 2712 | // read cat-name |
2713 | if (f.readLine(ch_tmp, ch_tmp_size) == -1) | 2713 | if (f.readLine(ch_tmp, ch_tmp_size) == -1) |
2714 | goto formatError; | 2714 | goto formatError; |
2715 | // check cat-name format | 2715 | // check cat-name format |
2716 | if (memcmp(ch_tmp, "== Category: ", 13) != 0) | 2716 | if (memcmp(ch_tmp, "== Category: ", 13) != 0) |
2717 | goto formatError; | 2717 | goto formatError; |
2718 | if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " ==", 3) != 0) | 2718 | if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " ==", 3) != 0) |
2719 | goto formatError; | 2719 | goto formatError; |
2720 | // copy cat-name | 2720 | // copy cat-name |
2721 | curCat.assign(ch_tmp + 13, strlen(ch_tmp) - 1 - 16); | 2721 | curCat.assign(ch_tmp + 13, strlen(ch_tmp) - 1 - 16); |
2722 | 2722 | ||
2723 | do { | 2723 | do { |
2724 | // find beginning of next entry | 2724 | // find beginning of next entry |
2725 | do { | 2725 | do { |
2726 | tmp = f.getch(); | 2726 | tmp = f.getch(); |
2727 | } while (tmp == '\n' && tmp != EOF && tmp != '='); | 2727 | } while (tmp == '\n' && tmp != EOF && tmp != '='); |
2728 | if (tmp == EOF) | 2728 | if (tmp == EOF) |
2729 | break; | 2729 | break; |
2730 | if (tmp == '=') { | 2730 | if (tmp == '=') { |
2731 | f.at(f.at()-1); | 2731 | f.at(f.at()-1); |
2732 | break; | 2732 | break; |
2733 | } | 2733 | } |
2734 | // decrement filepos by one | 2734 | // decrement filepos by one |
2735 | f.at(f.at()-1); | 2735 | f.at(f.at()-1); |
2736 | // read desc-line | 2736 | // read desc-line |
2737 | if (f.readLine(ch_tmp, ch_tmp_size) == -1) | 2737 | if (f.readLine(ch_tmp, ch_tmp_size) == -1) |
2738 | goto formatError; | 2738 | goto formatError; |
2739 | // check desc-line format | 2739 | // check desc-line format |
2740 | if (memcmp(ch_tmp, "-- ", 3) != 0) | 2740 | if (memcmp(ch_tmp, "-- ", 3) != 0) |
2741 | goto formatError; | 2741 | goto formatError; |
2742 | if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " --", 3) != 0) | 2742 | if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " --", 3) != 0) |
2743 | goto formatError; | 2743 | goto formatError; |
2744 | // add desc-line | 2744 | // add desc-line |
2745 | currItem.desc.assign(ch_tmp + 3, strlen(ch_tmp) - 1 - 6); | 2745 | currItem.desc.assign(ch_tmp + 3, strlen(ch_tmp) - 1 - 6); |
2746 | 2746 | ||
2747 | // read username-line | 2747 | // read username-line |
2748 | if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) | 2748 | if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) |
2749 | goto formatError; | 2749 | goto formatError; |
2750 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.name)) | 2750 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.name)) |
2751 | goto formatError; | 2751 | goto formatError; |
2752 | 2752 | ||
2753 | // read pw-line | 2753 | // read pw-line |
2754 | if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) | 2754 | if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) |
2755 | goto formatError; | 2755 | goto formatError; |
2756 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.pw)) | 2756 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.pw)) |
2757 | goto formatError; | 2757 | goto formatError; |
2758 | 2758 | ||
2759 | // read comment-line | 2759 | // read comment-line |
2760 | if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) | 2760 | if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) |
2761 | goto formatError; | 2761 | goto formatError; |
2762 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.comment)) | 2762 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.comment)) |
2763 | goto formatError; | 2763 | goto formatError; |
2764 | 2764 | ||
2765 | // read URL-line | 2765 | // read URL-line |
2766 | if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) | 2766 | if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) |
2767 | goto formatError; | 2767 | goto formatError; |
2768 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.url)) | 2768 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.url)) |
2769 | goto formatError; | 2769 | goto formatError; |
2770 | 2770 | ||
2771 | // read launcher-line | 2771 | // read launcher-line |
2772 | if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) | 2772 | if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) |
2773 | goto formatError; | 2773 | goto formatError; |
2774 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.launcher)) | 2774 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.launcher)) |
2775 | goto formatError; | 2775 | goto formatError; |
2776 | 2776 | ||
2777 | currItem.lockStat = true; | 2777 | currItem.lockStat = true; |
2778 | currItem.listViewPos = -1; | 2778 | currItem.listViewPos = -1; |
2779 | addEntry(curCat.c_str(), &currItem, true); | 2779 | addEntry(curCat.c_str(), &currItem, true); |
2780 | ++entriesRead; | 2780 | ++entriesRead; |
2781 | } while (1); | 2781 | } while (1); |
2782 | } while (1); | 2782 | } while (1); |
2783 | if (!entriesRead) | 2783 | if (!entriesRead) |
2784 | goto formatError; | 2784 | goto formatError; |
2785 | 2785 | ||
2786 | free(ch_tmp); | 2786 | free(ch_tmp); |
2787 | f.close(); | 2787 | f.close(); |
2788 | flagDirty(); | 2788 | flagDirty(); |
2789 | return e_success; | 2789 | return e_success; |
2790 | 2790 | ||
2791 | formatError: | 2791 | formatError: |
2792 | free(ch_tmp); | 2792 | free(ch_tmp); |
2793 | f.close(); | 2793 | f.close(); |
2794 | return e_fileFormat; | 2794 | return e_fileFormat; |
2795 | 2795 | ||
2796 | #endif | 2796 | #endif |
2797 | 2797 | ||
2798 | } | 2798 | } |
2799 | 2799 | ||
2800 | bool PwMDoc::textExtractEntry_PwM(const char *in, ssize_t in_size, string *out) | 2800 | bool PwMDoc::textExtractEntry_PwM(const char *in, ssize_t in_size, string *out) |
2801 | { | 2801 | { |
2802 | PWM_ASSERT(in && out); | 2802 | PWM_ASSERT(in && out); |
2803 | ssize_t i = 0, len = in_size - 1; | 2803 | ssize_t i = 0, len = in_size - 1; |
2804 | while (i < len) { | 2804 | while (i < len) { |
2805 | if (in[i] == ':') | 2805 | if (in[i] == ':') |
2806 | break; | 2806 | break; |
2807 | ++i; | 2807 | ++i; |
2808 | } | 2808 | } |
2809 | i += 2; | 2809 | i += 2; |
2810 | *out = ""; | 2810 | *out = ""; |
2811 | out->append(in + i, in_size - i - 1); | 2811 | out->append(in + i, in_size - i - 1); |
2812 | return true; | 2812 | return true; |
2813 | } | 2813 | } |
2814 | 2814 | ||
2815 | PwMerror PwMDoc::exportToGpasman(const QString *file) | 2815 | PwMerror PwMDoc::exportToGpasman(const QString *file) |
2816 | { | 2816 | { |
2817 | PWM_ASSERT(file); | 2817 | PWM_ASSERT(file); |
2818 | GpasmanFile gp; | 2818 | GpasmanFile gp; |
2819 | int ret; | 2819 | int ret; |
2820 | 2820 | ||
2821 | if (!unlockAll_tempoary()) | 2821 | if (!unlockAll_tempoary()) |
2822 | return e_lock; | 2822 | return e_lock; |
2823 | 2823 | ||
2824 | QString gpmPassword; | 2824 | QString gpmPassword; |
2825 | while (1) { | 2825 | while (1) { |
2826 | gpmPassword = requestNewMpw(0); | 2826 | gpmPassword = requestNewMpw(0); |
2827 | if (gpmPassword == "") { | 2827 | if (gpmPassword == "") { |
2828 | unlockAll_tempoary(true); | 2828 | unlockAll_tempoary(true); |
2829 | return e_noPw; | 2829 | return e_noPw; |