mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-10-07 04:47:14 +00:00
doc(sogo-tool): Add doc to detailed sogo-tool
This commit is contained in:
1 parent
f41ab2ed0c
commit
0df0e34073
8 files changed
+632
-129
No files matched your search
+70
-70
@@ -221,95 +221,95 @@
|
||||
count = [objects count];
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
content = [[[objects objectAtIndex: i] objectForKey: @"c_content"] stringByTrimmingSpaces];
|
||||
c_name = [[objects objectAtIndex: i] objectForKey: @"c_name"];
|
||||
if (is_calendar)
|
||||
{
|
||||
// We check for
|
||||
// BEGIN:VCALENDAR
|
||||
// ..
|
||||
// END:VCALENDAR
|
||||
iCalCalendar *calendar;
|
||||
{
|
||||
content = [[[objects objectAtIndex: i] objectForKey: @"c_content"] stringByTrimmingSpaces];
|
||||
c_name = [[objects objectAtIndex: i] objectForKey: @"c_name"];
|
||||
if (is_calendar)
|
||||
{
|
||||
// We check for
|
||||
// BEGIN:VCALENDAR
|
||||
// ..
|
||||
// END:VCALENDAR
|
||||
iCalCalendar *calendar;
|
||||
|
||||
if ([content length] < 30 ||
|
||||
if ([content length] < 30 ||
|
||||
[[content substringToIndex: 15] caseInsensitiveCompare: @"BEGIN:VCALENDAR"] != NSOrderedSame ||
|
||||
[[content substringFromIndex: [content length]-13] caseInsensitiveCompare: @"END:VCALENDAR"] != NSOrderedSame)
|
||||
{
|
||||
NSLog(@"Corrupted calendar item (missing tags) in path %@ with c_name = %@", folder, c_name);
|
||||
if (delete)
|
||||
[gcsFolder deleteContentWithName: c_name];
|
||||
[gcsFolder deleteContentWithName: c_name];
|
||||
rc = NO;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
calendar = [iCalCalendar parseSingleFromSource: content];
|
||||
if (!calendar)
|
||||
{
|
||||
NSLog(@"Corrupted calendar item (unparsable) in path %@ with c_name = %@", folder, c_name);
|
||||
if (delete)
|
||||
[gcsFolder deleteContentWithName: c_name];
|
||||
rc = NO;
|
||||
}
|
||||
else
|
||||
{
|
||||
iCalEvent *event;
|
||||
{
|
||||
NSLog(@"Corrupted calendar item (unparsable) in path %@ with c_name = %@", folder, c_name);
|
||||
if (delete)
|
||||
[gcsFolder deleteContentWithName: c_name];
|
||||
rc = NO;
|
||||
}
|
||||
else
|
||||
{
|
||||
iCalEvent *event;
|
||||
|
||||
event = (iCalEvent *) [calendar firstChildWithTag: @"vevent"];
|
||||
if (event)
|
||||
{
|
||||
iCalDateTime *startDate, *endDate;
|
||||
event = (iCalEvent *) [calendar firstChildWithTag: @"vevent"];
|
||||
if (event)
|
||||
{
|
||||
iCalDateTime *startDate, *endDate;
|
||||
|
||||
startDate = (iCalDateTime *) [event uniqueChildWithTag: @"dtstart"];
|
||||
if (![startDate dateTime])
|
||||
{
|
||||
NSLog(@"Missing start date of event in path %@ with c_name = %@ (%@)", folder, c_name, [event summary]);
|
||||
if (delete)
|
||||
[gcsFolder deleteContentWithName: c_name];
|
||||
rc = NO;
|
||||
}
|
||||
endDate = (iCalDateTime *) [event uniqueChildWithTag: @"dtend"];
|
||||
if (![endDate dateTime] && ![event hasDuration])
|
||||
{
|
||||
NSLog(@"Missing end date of event in path %@ with c_name = %@ (%@)", folder, c_name, [event summary]);
|
||||
if (delete)
|
||||
[gcsFolder deleteContentWithName: c_name];
|
||||
rc = NO;
|
||||
}
|
||||
if ([startDate dateTime] && [endDate dateTime])
|
||||
{
|
||||
NSComparisonResult comparison;
|
||||
startDate = (iCalDateTime *) [event uniqueChildWithTag: @"dtstart"];
|
||||
if (![startDate dateTime])
|
||||
{
|
||||
NSLog(@"Missing start date of event in path %@ with c_name = %@ (%@)", folder, c_name, [event summary]);
|
||||
if (delete)
|
||||
[gcsFolder deleteContentWithName: c_name];
|
||||
rc = NO;
|
||||
}
|
||||
endDate = (iCalDateTime *) [event uniqueChildWithTag: @"dtend"];
|
||||
if (![endDate dateTime] && ![event hasDuration])
|
||||
{
|
||||
NSLog(@"Missing end date of event in path %@ with c_name = %@ (%@)", folder, c_name, [event summary]);
|
||||
if (delete)
|
||||
[gcsFolder deleteContentWithName: c_name];
|
||||
rc = NO;
|
||||
}
|
||||
if ([startDate dateTime] && [endDate dateTime])
|
||||
{
|
||||
NSComparisonResult comparison;
|
||||
|
||||
comparison = [[startDate dateTime] compare: [endDate dateTime]];
|
||||
if (([event isAllDay] && comparison == NSOrderedDescending) ||
|
||||
(![event isAllDay] && comparison != NSOrderedAscending))
|
||||
{
|
||||
NSLog(@"Start date (%@) is not before end date (%@) for event in path %@ with c_name = %@ (%@)",
|
||||
[startDate dateTime], [endDate dateTime], folder, c_name, [event summary]);
|
||||
if (delete)
|
||||
[gcsFolder deleteContentWithName: c_name];
|
||||
rc = NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
comparison = [[startDate dateTime] compare: [endDate dateTime]];
|
||||
if (([event isAllDay] && comparison == NSOrderedDescending) ||
|
||||
(![event isAllDay] && comparison != NSOrderedAscending))
|
||||
{
|
||||
NSLog(@"Start date (%@) is not before end date (%@) for event in path %@ with c_name = %@ (%@)",
|
||||
[startDate dateTime], [endDate dateTime], folder, c_name, [event summary]);
|
||||
if (delete)
|
||||
[gcsFolder deleteContentWithName: c_name];
|
||||
rc = NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NGVCard *card;
|
||||
}
|
||||
else
|
||||
{
|
||||
NGVCard *card;
|
||||
|
||||
card = [NGVCard parseSingleFromSource: content];
|
||||
card = [NGVCard parseSingleFromSource: content];
|
||||
|
||||
if (!card)
|
||||
if (!card)
|
||||
{
|
||||
NSLog(@"Corrupted card item (unparsable) in path %@ with c_name = %@", folder, c_name);
|
||||
if (delete)
|
||||
[gcsFolder deleteContentWithName: c_name];
|
||||
rc = NO;
|
||||
NSLog(@"Corrupted card item (unparsable) in path %@ with c_name = %@", folder, c_name);
|
||||
if (delete)
|
||||
[gcsFolder deleteContentWithName: c_name];
|
||||
rc = NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -138,6 +138,8 @@
|
||||
sessionExpireMinutes = [[arguments objectAtIndex: 0] intValue];
|
||||
}
|
||||
|
||||
NSLog(@"Remove all sessions older than %d min", sessionExpireMinutes);
|
||||
|
||||
if (sessionExpireMinutes >= 0)
|
||||
{
|
||||
rc = [self expireUserSessionOlderThan: sessionExpireMinutes];
|
||||
|
||||
@@ -113,13 +113,13 @@ typedef enum
|
||||
" remove remove all ACL information of folder for user\n"
|
||||
" subscribe subscribe user to owner's folder\n"
|
||||
" unsubscribe unsubscribe user to owner's folder\n"
|
||||
" owner the user owning the folder\n"
|
||||
" owner the user owning the folder\n"
|
||||
" folder the folder - Calendar/<ID> or Contacts/<ID>\n"
|
||||
" user the user (or group without the @ prefix) to get/set rights for - 'ALL', '<default>', 'anonymous' are supported\n"
|
||||
" rights rights to add\n\n"
|
||||
"Example: sogo-tool manage-acl get jdoe Calendar/personal ALL\n\n"
|
||||
"Note: You can add only one access right at the time. To set them all at once,\n"
|
||||
" invoke 'remove' first to remove them all.\n\n");
|
||||
" rights rights to add\n\n"
|
||||
"Example: sogo-tool manage-acl get jdoe Calendar/personal ALL\n\n"
|
||||
"Note: You can add only one access right at the time. To set them all at once,\n"
|
||||
" invoke 'remove' first to remove them all.\n\n");
|
||||
}
|
||||
|
||||
- (BOOL) parseArguments
|
||||
|
||||
@@ -86,15 +86,15 @@
|
||||
/* we want to match the field value case-insensitively */
|
||||
recordEmail = [[record objectForKey: field] uppercaseString];
|
||||
if ([recordEmail length])
|
||||
{
|
||||
recordList = [doubleEmails objectForKey: recordEmail];
|
||||
if (!recordList)
|
||||
{
|
||||
recordList = [doubleEmails objectForKey: recordEmail];
|
||||
if (!recordList)
|
||||
{
|
||||
recordList = [NSMutableArray arrayWithCapacity: 5];
|
||||
[doubleEmails setObject: recordList forKey: recordEmail];
|
||||
}
|
||||
[recordList addObject: record];
|
||||
recordList = [NSMutableArray arrayWithCapacity: 5];
|
||||
[doubleEmails setObject: recordList forKey: recordEmail];
|
||||
}
|
||||
[recordList addObject: record];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) cleanupSingleRecords: (NSMutableDictionary *) doubleEmails
|
||||
@@ -220,21 +220,20 @@
|
||||
|
||||
recordsToRemove = [NSMutableArray arrayWithCapacity: (max - 1)];
|
||||
for (count = 0; count < max; count++)
|
||||
{
|
||||
if (count != keptRecord)
|
||||
{
|
||||
if (count != keptRecord)
|
||||
{
|
||||
currentRecord = [records objectAtIndex: count];
|
||||
[recordsToRemove
|
||||
addObject: [currentRecord objectForKey: @"c_name"]];
|
||||
}
|
||||
currentRecord = [records objectAtIndex: count];
|
||||
[recordsToRemove addObject: [currentRecord objectForKey: @"c_name"]];
|
||||
}
|
||||
}
|
||||
|
||||
return recordsToRemove;
|
||||
}
|
||||
|
||||
- (NSArray *) records: (NSArray *) records
|
||||
withLowestScores: (unsigned int *) scores
|
||||
count: (unsigned int) max
|
||||
count: (unsigned int) max
|
||||
{
|
||||
unsigned int count, highestScore;
|
||||
int highestScoreRecord;
|
||||
@@ -242,13 +241,13 @@
|
||||
highestScore = 0;
|
||||
highestScoreRecord = -1;
|
||||
for (count = 0; count < max; count++)
|
||||
{
|
||||
if (scores[count] > highestScore)
|
||||
{
|
||||
if (scores[count] > highestScore)
|
||||
{
|
||||
highestScore = scores[count];
|
||||
highestScoreRecord = count;
|
||||
}
|
||||
highestScore = scores[count];
|
||||
highestScoreRecord = count;
|
||||
}
|
||||
}
|
||||
|
||||
if (highestScoreRecord == -1)
|
||||
highestScoreRecord = 0;
|
||||
@@ -268,16 +267,15 @@
|
||||
|
||||
highestVersion = 0;
|
||||
for (count = 0; count < max; count++)
|
||||
{
|
||||
currentVersion = [[records objectAtIndex: count] objectForKey: @"c_version"];
|
||||
version = [currentVersion intValue];
|
||||
if (version > highestVersion)
|
||||
{
|
||||
currentVersion
|
||||
= [[records objectAtIndex: count] objectForKey: @"c_version"];
|
||||
version = [currentVersion intValue];
|
||||
if (version > highestVersion)
|
||||
{
|
||||
mostModified = count;
|
||||
highestVersion = version;
|
||||
}
|
||||
mostModified = count;
|
||||
highestVersion = version;
|
||||
}
|
||||
}
|
||||
|
||||
return mostModified;
|
||||
}
|
||||
@@ -291,25 +289,25 @@
|
||||
amount = 0;
|
||||
|
||||
if (!quickFields)
|
||||
{
|
||||
quickFields = [NSArray arrayWithObjects: @"c_givenname", @"c_cn",
|
||||
@"c_sn", @"c_screenname", @"c_l", @"c_mail",
|
||||
@"c_o", @"c_ou", @"c_telephonenumber", nil];
|
||||
[quickFields retain];
|
||||
}
|
||||
{
|
||||
quickFields = [NSArray arrayWithObjects: @"c_givenname", @"c_cn",
|
||||
@"c_sn", @"c_screenname", @"c_l", @"c_mail",
|
||||
@"c_o", @"c_ou", @"c_telephonenumber", nil];
|
||||
[quickFields retain];
|
||||
}
|
||||
|
||||
max = [quickFields count];
|
||||
for (count = 0; count < max; count++)
|
||||
{
|
||||
value = [record objectForKey: [quickFields objectAtIndex: count]];
|
||||
if ([value isKindOfClass: [NSString class]])
|
||||
{
|
||||
value = [record objectForKey: [quickFields objectAtIndex: count]];
|
||||
if ([value isKindOfClass: [NSString class]])
|
||||
{
|
||||
if ([value length])
|
||||
amount++;
|
||||
}
|
||||
else if ([value isKindOfClass: [NSNumber class]])
|
||||
amount++;
|
||||
if ([value length])
|
||||
amount++;
|
||||
}
|
||||
else if ([value isKindOfClass: [NSNumber class]])
|
||||
amount++;
|
||||
}
|
||||
|
||||
return amount;
|
||||
}
|
||||
@@ -323,15 +321,14 @@
|
||||
|
||||
highestQFields = 0;
|
||||
for (count = 0; count < max; count++)
|
||||
{
|
||||
currentQFields = [self amountOfFilledQuickFields: [records objectAtIndex: count]];
|
||||
if (currentQFields > highestQFields)
|
||||
{
|
||||
currentQFields
|
||||
= [self amountOfFilledQuickFields: [records objectAtIndex: count]];
|
||||
if (currentQFields > highestQFields)
|
||||
{
|
||||
mostQuickFields = count;
|
||||
highestQFields = currentQFields;
|
||||
}
|
||||
mostQuickFields = count;
|
||||
highestQFields = currentQFields;
|
||||
}
|
||||
}
|
||||
|
||||
return mostQuickFields;
|
||||
}
|
||||
@@ -399,10 +396,28 @@
|
||||
}
|
||||
|
||||
- (void) assignScores: (unsigned int *) scores
|
||||
toRecords: (NSArray *) records
|
||||
count: (unsigned int) max
|
||||
toRecords: (NSArray *) records
|
||||
count: (unsigned int) max
|
||||
withCardsInLists: (NSArray *) cardsInLists
|
||||
{
|
||||
/*
|
||||
Records is an Array of record which are duplicates of each other.
|
||||
The goal here is to know which one to keep and whoch ones to discard.
|
||||
We will assign a score to each record, the one with the best scores is kept
|
||||
Record which has been the last modified: +1
|
||||
Record has the most content: +2
|
||||
Record has the most quick field set: +3
|
||||
Record is in a list: +6
|
||||
|
||||
If two record have the same, for exemple, content. It's the first one on the list
|
||||
that will get the points.
|
||||
If two recors have the same score. t's the first one on the list
|
||||
that will get the points.
|
||||
|
||||
quick fiels are =("c_givenname": Firstname, @"c_cn": Display,
|
||||
@"c_sn": LastName, @"c_screenname": Screen Name @"c_l": City, @"c_mail": mails,
|
||||
@"c_o": organisation, @"c_ou": organisation unit, @"c_telephonenumber": telephone)
|
||||
*/
|
||||
int recordIndex;
|
||||
|
||||
recordIndex = [self mostModifiedRecord: records count: max];
|
||||
|
||||
@@ -634,7 +634,7 @@
|
||||
|
||||
if (authname == nil || authpwd == nil)
|
||||
{
|
||||
NSLog(@"To update Sieve scripts, you must provide the \"-p credentialFile\" parameter");
|
||||
NSLog(@"To update Sieve scripts, you must provide the \"-c credentialFile\" parameter");
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
||||
@@ -210,8 +210,7 @@
|
||||
GCSFolder *folder;
|
||||
BOOL rc;
|
||||
|
||||
folderPath = [NSString stringWithFormat: @"/Users/%@/Calendar/%@",
|
||||
username, folderId];
|
||||
folderPath = [NSString stringWithFormat: @"/Users/%@/Calendar/%@", username, folderId];
|
||||
folder = [fom folderAtPath: folderPath];
|
||||
if (folder)
|
||||
rc = [self truncateEntriesFromFolder: folder usingDate: date];
|
||||
@@ -238,12 +237,13 @@
|
||||
// in the default timezone.
|
||||
s = [NSString stringWithFormat: @"%@ GMT", date];
|
||||
d = [NSCalendarDate dateWithString: s calendarFormat: @"%Y-%m-%dT%H:%M:%S %Z"];
|
||||
NSLog(@"Date is: %@", d);
|
||||
fom = [GCSFolderManager defaultFolderManager];
|
||||
|
||||
if (d && fom)
|
||||
rc = [self processFolder: folder
|
||||
ofUser: username
|
||||
date: d
|
||||
date: d
|
||||
withFoM: fom];
|
||||
else
|
||||
rc = NO;
|
||||
|
||||
@@ -146,6 +146,9 @@
|
||||
[helpString appendFormat: @"\t%-20@-- %@\n",
|
||||
command, [currentTool objectAtIndex: 1]];
|
||||
}
|
||||
[helpString appendString: @"\n Visit https://www.sogo.nu/files/docs/SOGoInstallationGuide.html#_using_sogo_tool to get more infos"];
|
||||
|
||||
|
||||
|
||||
NSLog (@"%@", helpString);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user