summaryrefslogtreecommitdiff
path: root/plugins/Db3x_mmap/src/dbtool/user.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Db3x_mmap/src/dbtool/user.cpp')
-rw-r--r--plugins/Db3x_mmap/src/dbtool/user.cpp59
1 files changed, 31 insertions, 28 deletions
diff --git a/plugins/Db3x_mmap/src/dbtool/user.cpp b/plugins/Db3x_mmap/src/dbtool/user.cpp
index d61add09d4..ac200d2409 100644
--- a/plugins/Db3x_mmap/src/dbtool/user.cpp
+++ b/plugins/Db3x_mmap/src/dbtool/user.cpp
@@ -16,56 +16,59 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+
#include "..\commonheaders.h"
static DBContact user;
static int phase;
static DWORD ofsUser;
-int WorkSettingsChain(DWORD ofsContact,DBContact *dbc,int firstTime);
-int WorkEventChain(DWORD ofsContact,DBContact *dbc,int firstTime);
-
-int WorkUser(int firstTime)
+int CDb3Base::WorkUser(int firstTime)
{
int first = 0;
if (firstTime) {
- AddToStatus(STATUS_MESSAGE,TranslateT("Processing user data"));
- if (!SignatureValid(dbhdr.ofsUser,DBCONTACT_SIGNATURE)) {
- AddToStatus(STATUS_ERROR,TranslateT("User corrupted, this could cause major problems"));
+ cb->pfnAddLogMessage(STATUS_MESSAGE,TranslateT("Processing user data"));
+ if ( !SignatureValid(m_dbHeader.ofsUser, DBCONTACT_SIGNATURE)) {
+ cb->pfnAddLogMessage(STATUS_ERROR,TranslateT("User corrupted, this could cause major problems"));
return ERROR_NO_MORE_ITEMS;
}
- if (ReadSegment(dbhdr.ofsUser,&user,sizeof(DBContact)) != ERROR_SUCCESS)
+
+ if ( ReadSegment(m_dbHeader.ofsUser,&user,sizeof(DBContact)) != ERROR_SUCCESS)
return ERROR_NO_MORE_ITEMS;
+
if (user.ofsNext) {
- AddToStatus(STATUS_WARNING,TranslateT("More than one user contact: keeping only first"));
+ cb->pfnAddLogMessage(STATUS_WARNING,TranslateT("More than one user contact: keeping only first"));
user.ofsNext = 0;
}
+
if ((ofsUser = WriteSegment(WSOFS_END,&user,sizeof(DBContact))) == WS_ERROR)
return ERROR_HANDLE_DISK_FULL;
- dbhdr.ofsUser = ofsUser;
+
+ m_dbHeader.ofsUser = ofsUser;
phase = 0;
first = 1;
}
+
+ int ret;
switch(phase) {
- int ret;
+ case 0:
+ ret = WorkSettingsChain(ofsUser,&user,first);
+ if (ret == ERROR_NO_MORE_ITEMS) {
+ phase++; first = 1;
+ }
+ else if (ret) return ret;
+ else break;
- case 0:
- ret = WorkSettingsChain(ofsUser,&user,first);
- if (ret == ERROR_NO_MORE_ITEMS) {
- phase++; first = 1;
- }
- else if (ret) return ret;
- else break;
- case 1:
- ret = WorkEventChain(ofsUser,&user,first);
- if (ret == ERROR_NO_MORE_ITEMS) {
- if (WriteSegment(ofsUser,&user,sizeof(DBContact)) == WS_ERROR)
- return ERROR_HANDLE_DISK_FULL;
- return ERROR_NO_MORE_ITEMS;
- }
- else if (ret) return ret;
- break;
+ case 1:
+ ret = WorkEventChain(ofsUser,&user,first);
+ if (ret == ERROR_NO_MORE_ITEMS) {
+ if (WriteSegment(ofsUser,&user,sizeof(DBContact)) == WS_ERROR)
+ return ERROR_HANDLE_DISK_FULL;
+ return ERROR_NO_MORE_ITEMS;
+ }
+ else if (ret) return ret;
+ break;
}
return ERROR_SUCCESS;
-} \ No newline at end of file
+}