예제 #1
0
bool ReaderViewNative::saveHistory( lString16 filename )
{
	if ( !filename.empty() )
		historyFileName = filename;
    if ( historyFileName.empty() )
    	return false;
	if ( _docview->isDocumentOpened() ) {
		CRLog::debug("ReaderViewNative::saveHistory() : saving position");
	    _docview->savePosition();
	}
	CRLog::info("Trying to save history to file %s", LCSTR(historyFileName));
    CRFileHist * hist = _docview->getHistory();
    LVStreamRef stream = LVOpenFileStream(historyFileName.c_str(), LVOM_WRITE);
    if ( stream.isNull() ) {
    	CRLog::error("Cannot create file %s for writing", LCSTR(historyFileName));
    	return false;
    }
    if ( _docview->isDocumentOpened() )
    	_docview->savePosition();
    return hist->saveToStream( stream.get() );
}
예제 #2
0
bool ReaderViewNative::loadHistory( lString16 filename )
{
    CRFileHist * hist = _docview->getHistory();
	if ( !filename.empty() )
		historyFileName = filename;
    historyFileName = filename;
    if ( historyFileName.empty() ) {
    	CRLog::error("No history file name specified");
    	return false;
    }
	CRLog::info("Trying to load history from file %s", LCSTR(historyFileName));
    LVStreamRef stream = LVOpenFileStream(historyFileName.c_str(), LVOM_READ);
    if ( stream.isNull() ) {
    	CRLog::error("Cannot open file %s", LCSTR(historyFileName));
    	return false;
    }
    bool res = hist->loadFromStream( stream );
    if ( res )
    	CRLog::info("%d items found", hist->getRecords().length());
    else
    	CRLog::error("Cannot read history file content");
    return res;
}
예제 #3
0
파일: hist.cpp 프로젝트: Frenzie/crengine
 /// called on closing
 virtual void OnTagClose( const lChar16 * nsname, const lChar16 * tagname )
 {
     if ( lStr_cmp(nsname, "FictionBookMarks")==0 && state==in_fbm ) {
         state = in_xml;
     } else if ( lStr_cmp(tagname, "file")==0 && state==in_file ) {
         state = in_fbm;
         if ( _curr_file )
             _hist->getRecords().add( _curr_file );
         _curr_file = NULL;
     } else if ( lStr_cmp(tagname, "file-info")==0 && state==in_file_info ) {
         state = in_file;
     } else if ( lStr_cmp(tagname, "bookmark-list")==0 && state==in_bm_list ) {
         state = in_file;
     } else if ( lStr_cmp(tagname, "doc-title")==0 && state==in_title ) {
         state = in_file_info;
     } else if ( lStr_cmp(tagname, "doc-author")==0 && state==in_author ) {
         state = in_file_info;
     } else if ( lStr_cmp(tagname, "doc-series")==0 && state==in_series ) {
         state = in_file_info;
     } else if ( lStr_cmp(tagname, "doc-filename")==0 && state==in_filename ) {
         state = in_file_info;
     } else if ( lStr_cmp(tagname, "doc-filepath")==0 && state==in_filepath ) {
         state = in_file_info;
     } else if ( lStr_cmp(tagname, "doc-filesize")==0 && state==in_filesize ) {
         state = in_file_info;
     } else if ( lStr_cmp(tagname, "bookmark")==0 && state==in_bm ) {
         state = in_bm_list;
         if ( _curr_bookmark ) {
             if ( _curr_bookmark->getType() == bmkt_lastpos ) {
                 _curr_file->setLastPos(_curr_bookmark);
                 delete _curr_bookmark;
             } else {
                 _curr_file->getBookmarks().add(_curr_bookmark);
             }
             _curr_bookmark = NULL;
         }
     } else if ( lStr_cmp(tagname, "start-point")==0 && state==in_start_point ) {
         state = in_bm;
     } else if ( lStr_cmp(tagname, "end-point")==0 && state==in_end_point ) {
         state = in_bm;
     } else if ( lStr_cmp(tagname, "header-text")==0 && state==in_header_txt ) {
         state = in_bm;
     } else if ( lStr_cmp(tagname, "selection-text")==0 && state==in_selection_txt ) {
         state = in_bm;
     } else if ( lStr_cmp(tagname, "comment-text")==0 && state==in_comment_txt ) {
         state = in_bm;
     }
 }