Changeset 65 for trunk/src/MainPter.cxx

Show
Ignore:
Timestamp:
04/14/06 16:24:42 (3 years ago)
Author:
jordi
Message:

The Main presenter now can reload encrypted files without bothering the user about password, unless the document's password has been changed. In this case, it will behaviour like opening the file as new.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/MainPter.cxx

    r64 r65  
    245245    IMainView &view = getView (); 
    246246    gchar *fileName = view.openFileDialog (); 
    247     openDocument (fileName, TRUE); 
     247    openDocument (fileName, NULL, TRUE); 
    248248    g_free (fileName); 
    249249} 
     
    263263    gdouble currentZoom = m_Document->getZoom (); 
    264264    // Reopen the document. 
    265     openDocument (m_Document->getFileName (), FALSE);     
     265    openDocument (m_Document->getFileName (), m_Document->getPassword (),  
     266                  FALSE);  
    266267    // And restore the state 
    267268    m_Document->setZoom (currentZoom); 
     
    359360///                 NULL then that means the user didn't wanted to 
    360361///                 open a file, so this function won't do anything. 
     362/// @param oldPassword This is only used when reloading. It is the last 
     363///                    password that was used to open a file, and will be 
     364///                    used to open the file the first try before asking 
     365///                    to the user. For opening a new file, just set to NULL. 
    361366/// @param canShowPage Set to TRUE if the application should show the page  
    362367///                    after the loading or not. This is useful when reloading 
     
    365370/// 
    366371void 
    367 MainPter::openDocument (const gchar *fileName, gboolean canShowPage) 
     372MainPter::openDocument (const gchar *fileName, const gchar *oldPassword, 
     373                        gboolean canShowPage) 
    368374{ 
    369375    // if fileName is NULL, then the user cancelled the operation. 
     
    372378    if ( NULL != fileName ) 
    373379    { 
    374         GError *error = NULL; 
    375         if ( m_Document->loadFile (fileName, NULL, &error) ) 
     380        GError *error = NULL;         
     381        if ( m_Document->loadFile (fileName, oldPassword, &error) ) 
    376382        { 
    377383            // Now that the document has been loaded, just reset the initial 
     
    380386        } 
    381387        else 
    382         {             
     388        { 
    383389            // We got an error, but also can be that the file is encrypted. 
    384390            if ( DocumentErrorEncrypted == error->code )