| 162 | | // TODO |
| | 161 | // Now we got an encrypted file. |
| | 162 | // Prompt for the password up to three time, until the password |
| | 163 | // is correct or the user cancels the password dialog. |
| | 164 | int passwordTries = 0; |
| | 165 | gchar *password = NULL; |
| | 166 | gboolean loaded = FALSE; |
| | 167 | do |
| | 168 | { |
| | 169 | g_free (password); |
| | 170 | password = getView ().promptPasswordDialog (); |
| | 171 | loaded = m_Document->loadFile (fileName, password, NULL); |
| | 172 | } while ( 3 > ++passwordTries && |
| | 173 | NULL != password && |
| | 174 | !loaded); |
| | 175 | |
| | 176 | // We are go, just check if we could load it or show the |
| | 177 | // error. |
| | 178 | if ( loaded ) |
| | 179 | { |
| | 180 | // Phew, finally loaded. Set the initial state. |
| | 181 | setInitialState (); |
| | 182 | } |
| | 183 | else if ( NULL != password ) |
| | 184 | { |
| | 185 | // We didn't get the correct password, but the user |
| | 186 | // tried, because the password is not NULL. |
| | 187 | getView ().showErrorMessage (_("Error Loading File"), |
| | 188 | _("The password you have supplier is not a" |
| | 189 | "valid password for this file.")); |
| | 190 | g_free (password); |
| | 191 | } |