mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-05-19 02:15:36 +00:00
Refactored GCSFolder: -writeContent and fixed sogo-tool restore
This commit is contained in:
+33
-5
@@ -1,8 +1,6 @@
|
||||
/* SOGoToolRestore.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2009-2012 Inverse inc.
|
||||
*
|
||||
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
* Copyright (C) 2009-2014 Inverse inc.
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -43,6 +41,10 @@
|
||||
#import <SOGo/SOGoUserProfile.h>
|
||||
#import <SOGo/SOGoUserSettings.h>
|
||||
|
||||
#import <NGCards/iCalCalendar.h>
|
||||
#import <NGCards/NGVCard.h>
|
||||
#import <NGCards/NGVList.h>
|
||||
|
||||
#import "SOGoTool.h"
|
||||
|
||||
/* TODO:
|
||||
@@ -116,6 +118,29 @@ typedef enum SOGoToolRestoreMode {
|
||||
" sogo-tool restore -p /tmp/foo bob\n");
|
||||
}
|
||||
|
||||
- (Class) parsingClassForContent: (NSString *) theContent
|
||||
{
|
||||
CardGroup *cardEntry;
|
||||
NSString *firstTag;
|
||||
Class objectClass;
|
||||
|
||||
objectClass = Nil;
|
||||
|
||||
cardEntry = [CardGroup parseSingleFromSource: theContent];
|
||||
if (cardEntry)
|
||||
{
|
||||
firstTag = [[cardEntry tag] uppercaseString];
|
||||
if ([firstTag isEqualToString: @"VCARD"])
|
||||
objectClass = [NGVCard class];
|
||||
else if ([firstTag isEqualToString: @"VLIST"])
|
||||
objectClass = [NGVList class];
|
||||
else
|
||||
objectClass = [iCalCalendar class];
|
||||
}
|
||||
|
||||
return objectClass;
|
||||
}
|
||||
|
||||
- (BOOL) checkDirectory
|
||||
{
|
||||
NSFileManager *fm;
|
||||
@@ -347,11 +372,12 @@ typedef enum SOGoToolRestoreMode {
|
||||
- (BOOL) restoreRecords: (NSArray *) records
|
||||
ofFolder: (GCSFolder *) gcsFolder
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
NSDictionary *existingRecords, *currentRecord;
|
||||
NSString *cName, *cContent;
|
||||
int count, max;
|
||||
NSAutoreleasePool *pool;
|
||||
|
||||
unsigned int version;
|
||||
int count, max;
|
||||
BOOL rc;
|
||||
|
||||
if (records)
|
||||
@@ -375,6 +401,8 @@ typedef enum SOGoToolRestoreMode {
|
||||
NSLog (@"restoring record '%@'", cName);
|
||||
cContent = [currentRecord objectForKey: @"c_content"];
|
||||
[gcsFolder writeContent: cContent
|
||||
fromComponent: [[self parsingClassForContent: cContent] parseSingleFromSource: cContent]
|
||||
container: nil
|
||||
toName: cName
|
||||
baseVersion: &version];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user