Monotone-Parent: f06ad83d51ba56ba4489d76a7acc0985afe86e54

Monotone-Revision: d98519ee9416f281001d26da0a9ba8a76729997b

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2007-05-25T21:19:31
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2007-05-25 21:19:31 +00:00
parent 3d81297d22
commit a766f319ef
14 changed files with 49 additions and 1420 deletions

View File

@@ -1,5 +1,14 @@
2007-05-25 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* UI/MailerUI/UIxMailFolderMenu.[hm]: removed module, obsoleted by
new javascript code and the new UIxMailAccountActions class.
* UI/MailerUI/UIxMailTree.[hm]: removed module, obsoleted by new
javascript code and the new UIxMailAccountActions class.
* UI/MailerUI/UIxMailTreeBlock.[hm]: removed module, obsoleted by
new javascript code and the new UIxMailAccountActions class.
* UI/MailerUI/UIxMailAccountActions.m ([UIxMailAccountActions
-listMailboxesAction]): new method that returns a json-formatted
tree of all the mailboxes available to the current user.

View File

@@ -100,16 +100,16 @@
/* Tree */
"SentFolderName" = "Éléments envoyés";
"SentFolderName" = "Envoyés";
"TrashFolderName" = "Corbeille";
"InboxFolderName" = "Boite de réception";
"InboxFolderName" = "Courrier entrant";
"DraftsFolderName" = "Brouillons";
"SieveFolderName" = "Filtres";
"Folders" = "Dossiers";
/* MailMoveToPopUp */
"MoveTo" = "Déplacer vers";
"MoveTo" = "Déplacer vers";
/* Address Popup menu */
"Add to Address Book..." = "Ajouter au carnet d'adresses";

View File

@@ -17,10 +17,6 @@ MailerUI_OBJC_FILES += \
WOContext+UIxMailer.m \
\
UIxMailMainFrame.m \
# UIxMailTree.m \
# UIxMailTreeBlock.m \
# UIxMailTreeBlockJS.m \
# UIxMailFolderMenu.m \
\
UIxMailListView.m \
UIxMailView.m \

View File

@@ -1,46 +0,0 @@
/* UIxMailFolderMenu.h - this file is part of SOGo
*
* Copyright (C) 2006 Inverse groupe conseil
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
* 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
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef UIXMAILFOLDERMENU_H
#define UIXMAILFOLDERMENU_H
#import "UIxMailTree.h"
@class NSArray;
@interface UIxMailFolderMenu : UIxMailTree
{
NSString *menuId;
NSString *parentMenu;
}
- (void) setMenuId: (NSString *) newMenuId;
- (NSString *) menuId;
- (void) setParentMenu: (NSString *) newParentMenu;
- (NSString *) parentMenu;
- (NSArray *) levelledNodes;
@end
#endif /* UIXMAILFOLDERMENU_H */

View File

@@ -1,84 +0,0 @@
/* UIxMailFolderMenu.m - this file is part of SOGo
*
* Copyright (C) 2006 Inverse groupe conseil
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
* 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
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#import <Foundation/NSArray.h>
#import <Foundation/NSString.h>
#import "UIxMailTreeBlock.h"
#import "UIxMailFolderMenu.h"
@implementation UIxMailFolderMenu
- (void) setMenuId: (NSString *) newMenuId
{
menuId = newMenuId;
}
- (NSString *) menuId
{
return menuId;
}
- (void) setParentMenu: (NSString *) newParentMenu
{
parentMenu = newParentMenu;
}
- (NSString *) parentMenu
{
return parentMenu;
}
- (NSArray *) levelledNodes
{
NSEnumerator *nodes;
NSMutableArray *levelledNodes;
UIxMailTreeBlock *block;
levelledNodes = [NSMutableArray new];
[levelledNodes autorelease];
nodes = [[self flattenedNodes] objectEnumerator];
block = [nodes nextObject];
while (block)
{
if ([block parent] == [parentMenu intValue])
[levelledNodes addObject: block];
block = [nodes nextObject];
}
return levelledNodes;
}
- (NSString *) iconForMenuItem
{
NSString *iconName;
iconName = [item iconName];
if (!iconName)
iconName = [self defaultIconName];
return [self urlForResourceFilename: iconName];
}
@end

View File

@@ -19,8 +19,10 @@
02111-1307, USA.
*/
#import <Mailer/SOGoMailObject.h>
#import <SOGo/NSString+Utilities.h>
#import <SoObjects/Mailer/SOGoMailObject.h>
#import <SoObjects/Mailer/SOGoMailAccounts.h>
#import <SoObjects/SOGo/NSString+Utilities.h>
#import <SoObjects/SOGo/NSObject+Utilities.h>
#import <SOGoUI/UIxComponent.h>
#import "UIxMailMainFrame.h"
@@ -48,6 +50,14 @@ static NSString *treeRootClassName = nil;
}
/* accessors */
- (NSString *) mailAccounts
{
SOGoMailAccounts *co;
co = [self clientObject];
return [[co fetchAllIdentities] jsonRepresentation];
}
- (NSString *)treeRootClassName {
return treeRootClassName;
@@ -186,25 +196,25 @@ static NSString *treeRootClassName = nil;
}
/* FIXME: migrated methods which might not work yet... */
#warning check this
- (NSString *) mailFolderName
{
NSMutableArray *mailboxes;
SOGoMailObject *currentObject;
// #warning check this
// - (NSString *) mailFolderName
// {
// NSMutableArray *mailboxes;
// SOGoMailObject *currentObject;
mailboxes = [NSMutableArray new];
[mailboxes autorelease];
// mailboxes = [NSMutableArray new];
// [mailboxes autorelease];
currentObject = [self clientObject];
while (![currentObject isKindOfClass: [SOGoMailAccounts class]])
{
[mailboxes insertObject: [currentObject nameInContainer] atIndex: 0];
currentObject = [currentObject container];
}
// currentObject = [self clientObject];
// while (![currentObject isKindOfClass: [SOGoMailAccounts class]])
// {
// [mailboxes insertObject: [currentObject nameInContainer] atIndex: 0];
// currentObject = [currentObject container];
// }
return [NSString stringWithFormat: @"/%@",
[mailboxes componentsJoinedByString: @"/"]];
}
// return [NSString stringWithFormat: @"/%@",
// [mailboxes componentsJoinedByString: @"/"]];
// }
- (id) composeAction
{

View File

@@ -1,44 +0,0 @@
/* UIxMailTree.h - this file is part of $PROJECT_NAME_HERE$
*
* Copyright (C) 2006 Inverse groupe conseil
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
* 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
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef UIXMAILTREE_H
#define UIXMAILTREE_H
#import <SOGoUI/UIxComponent.h>
@class NSString;
@interface UIxMailTree : UIxComponent
{
NSString *rootClassName;
NSString *treeFolderAction;
NSMutableArray *flattenedNodes;
id rootNodes;
id item;
}
- (NSArray *) flattenedNodes;
- (NSString *) defaultIconName;
@end
#endif /* UIXMAILTREE_H */

View File

@@ -1,716 +0,0 @@
/*
Copyright (C) 2004 SKYRIX Software AG
This file is part of OpenGroupware.org.
OGo is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
OGo is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public
License along with OGo; see the file COPYING. If not, write to the
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
#import "common.h"
#import <SoObjects/Mailer/SOGoMailBaseObject.h>
#import <SoObjects/Mailer/SOGoMailAccount.h>
#import <SoObjects/Mailer/SOGoMailFolder.h>
#import <NGObjWeb/SoComponent.h>
#import <NGObjWeb/SoObject+SoDAV.h>
#import "UIxMailTree.h"
#import "UIxMailTreeBlock.h"
/*
Support special icons:
tbtv_leaf_corner_17x17.gif
tbtv_inbox_17x17.gif
tbtv_drafts_17x17.gif
tbtv_sent_17x17.gif
tbtv_trash_17x17.gif
*/
@interface NSString(DotCutting)
- (NSString *)stringByCuttingOffAtDotsWhenExceedingLength:(int)_maxLength;
- (NSString *)titleForSOGoIMAP4String;
@end
@implementation UIxMailTree
static BOOL debugBlocks = NO;
+ (void)initialize
{
[UIxMailTreeBlock class]; // ensure that globals are initialized
}
- (id) init
{
if ((self = [super init]))
{
flattenedNodes = nil;
}
return self;
}
- (void) dealloc
{
[treeFolderAction release];
[rootClassName release];
[rootNodes release];
[item release];
[flattenedNodes release];
[super dealloc];
}
/* icons */
- (NSString *) defaultIconName
{
return @"tbtv_leaf_corner_17x17.gif";
}
- (NSString *)iconNameForType:(NSString *)_type {
if (![_type isNotNull])
return [self defaultIconName];
//return @"tbtv_drafts_17x17.gif";
return [self defaultIconName];
}
/* accessors */
- (void)setRootClassName:(id)_rootClassName {
ASSIGNCOPY(rootClassName, _rootClassName);
}
- (id)rootClassName {
return rootClassName;
}
- (void)setItem:(id)_item {
ASSIGN(item, _item);
}
- (id)item {
return item;
}
- (void)setTreeFolderAction:(NSString *)_action {
ASSIGNCOPY(treeFolderAction, _action);
}
- (NSString *)treeFolderAction {
return treeFolderAction;
}
- (NSString *)itemIconName {
// TODO: only called once!
NSString *ftype;
ftype = [[self item] valueForKey:@"outlookFolderClass"];
return [self iconNameForType:ftype];
}
/* fetching subfolders */
- (NSArray *)fetchSubfoldersOfObject:(id)_object {
/* Walk over toManyRelationshipKeys and lookup the controllers for them. */
NSMutableArray *ma;
NSArray *names;
unsigned i, count;
if ((names = [_object toManyRelationshipKeys]) == nil) {
if (debugBlocks) [self logWithFormat:@"no to-many: %@", _object];
return nil;
}
if (debugBlocks) {
[self logWithFormat:@"to-many: %@ %@", _object,
[names componentsJoinedByString:@","]];
}
count = [names count];
ma = [NSMutableArray arrayWithCapacity:(count + 1)];
for (i = 0; i < count; i++) {
id folder;
// TODO: use some context or reuse the main context?
folder = [_object lookupName:[names objectAtIndex:i] inContext:nil
acquire:NO];
if (folder == nil) {
if (debugBlocks) {
[self logWithFormat:@" DID NOT FIND FOLDER %@: %@",
_object,
[names objectAtIndex:i]];
}
continue;
}
if ([folder isKindOfClass:[NSException class]]) {
if (debugBlocks) {
[self logWithFormat:@" FOLDER LOOKUP EXCEPTION %@: %@",
[names objectAtIndex:i], folder];
}
continue;
}
[ma addObject:folder];
}
if (debugBlocks)
[self logWithFormat:@" returning: %@ %@", _object, ma];
return ma;
}
/* navigation nodes */
- (BOOL)isRootObject:(id)_object {
if (![_object isNotNull]) {
[self warnWithFormat:@"(%s): got to root by nil lookup ...",
__PRETTY_FUNCTION__];
return YES;
}
if ([_object isKindOfClass:NSClassFromString(@"SOGoUserFolder")])
return YES;
return [_object isKindOfClass:NSClassFromString([self rootClassName])];
}
- (NSString *)treeNavigationLinkForObject:(id)_object
atDepth:(int)_depth
{
NSMutableString *link;
int i;
link = [NSMutableString new];
[link autorelease];
for (i = 0; i < _depth; i++)
[link appendString: @"../"];
[link appendFormat: @"%@/%@",
[_object nameInContainer],
[self treeFolderAction]];
return link;
}
- (void) getTitle: (NSString **)_t
folderType: (NSString **)_ft
andIcon: (NSString **)_icon
forObject: (id)_object
{
// TODO: need to refactor for reuse!
NSString *ftype;
unsigned len;
// if ([_object respondsToSelector: @selector (outlookFolderClass)])
// ftype = [_object outlookFolderClass];
// else
ftype = [_object valueForKey:@"outlookFolderClass"];
len = [ftype length];
*_ft = nil;
switch (len) {
case 8:
if ([ftype isEqualToString:@"IPF.Sent"]) {
*_t = [self labelForKey:@"SentFolderName"];
*_icon = @"tbtv_sent_17x17.gif";
*_ft = @"sent";
return;
}
break;
case 9:
if ([ftype isEqualToString:@"IPF.Inbox"]) {
*_t = [self labelForKey:@"InboxFolderName"];
*_icon = @"tbtv_inbox_17x17.gif";
*_ft = @"inbox";
return;
}
if ([ftype isEqualToString:@"IPF.Trash"]) {
*_t = [self labelForKey:@"TrashFolderName"];
*_icon = @"tbtv_trash_17x17.gif";
*_ft = @"trash";
return;
}
break;
case 10:
if ([ftype isEqualToString:@"IPF.Drafts"]) {
*_t = [self labelForKey:@"DraftsFolderName"];
*_icon = @"tbtv_drafts_17x17.gif";
*_ft = @"drafts";
return;
}
// if ([ftype isEqualToString:@"IPF.Filter"]) {
// *_t = [self labelForKey:@"SieveFolderName"];
// *_icon = nil;
// *_ft = @"sieve";
// return;
// }
break;
}
*_t = [_object davDisplayName];
*_icon = nil;
if ([_object isKindOfClass:NSClassFromString(@"SOGoMailFolder")])
*_icon = nil;
else if ([_object isKindOfClass:NSClassFromString(@"SOGoMailAccount")]) {
*_icon = @"tbtv_account_17x17.gif";
*_ft = @"account";
/* title processing is somehow Agenor specific and should be done in UI */
*_t = [[_object nameInContainer] titleForSOGoIMAP4String];
}
else if ([_object isKindOfClass:NSClassFromString(@"SOGoMailAccounts")])
*_icon = @"tbtv_account_17x17.gif";
else if ([_object isKindOfClass:NSClassFromString(@"SOGoUserFolder")])
*_icon = @"tbtv_inbox_17x17.gif";
else {
// TODO: use drafts icon for other SOGo folders
*_icon = @"tbtv_drafts_17x17.gif";
}
}
- (UIxMailTreeBlock *) treeNavigationBlockForLeafNode: (id) _o
atDepth: (int) _d
{
UIxMailTreeBlock *md;
NSString *n, *i, *ft;
id blocks;
/*
Trigger plus in treeview if it has subfolders. It is an optimization that
we do not generate blocks for folders which are not displayed anyway.
*/
blocks = [[_o toManyRelationshipKeys] count] > 0
? UIxMailTreeHasChildrenMarker
: nil;
[self getTitle: &n folderType: &ft andIcon: &i forObject:_o];
md = [UIxMailTreeBlock blockWithName: nil
title: n
iconName: i
link: [self treeNavigationLinkForObject:_o atDepth:_d]
isPathNode:NO
isActiveNode:NO
childBlocks: blocks];
return md;
}
- (UIxMailTreeBlock *)treeNavigationBlockForRootNode:(id)_object {
/*
This generates the block for the root object (root of the tree, we get
there by walking up the chain starting with the client object).
*/
UIxMailTreeBlock *md;
NSMutableArray *blocks;
NSArray *folders;
NSString *title, *icon, *ft;
unsigned i, count;
if (debugBlocks) {
[self logWithFormat:@"block for root node 0x%08X<%@>",
_object, NSStringFromClass([_object class])];
}
/* process child folders */
folders = [self fetchSubfoldersOfObject:_object];
count = [folders count];
blocks = [NSMutableArray arrayWithCapacity:count];
for (i = 0; i < count; i++) {
id block;
block = [self treeNavigationBlockForLeafNode: [folders objectAtIndex:i]
atDepth:0];
if ([block isNotNull]) [blocks addObject:block];
}
if ([blocks count] == 0)
blocks = nil;
/* build block */
[self getTitle:&title folderType: &ft andIcon:&icon forObject:_object];
md = [UIxMailTreeBlock blockWithName: [_object nameInContainer]
title: title
iconName: icon
link: [@"../" stringByAppendingString:
[_object nameInContainer]]
isPathNode: YES
isActiveNode: YES
childBlocks: blocks];
return md;
}
- (UIxMailTreeBlock *) fullTreeNavigationBlockForNode: (id)_object
{
UIxMailTreeBlock *md;
NSMutableArray *blocks;
NSArray *folders;
NSString *title, *icon, *ft;
unsigned i, count;
if (debugBlocks)
[self logWithFormat:@"block for root node 0x%08X<%@>",
_object, NSStringFromClass([_object class])];
folders = [self fetchSubfoldersOfObject: _object];
count = [folders count];
blocks = [NSMutableArray arrayWithCapacity: count];
for (i = 0; i < count; i++)
{
id block;
block = [self fullTreeNavigationBlockForNode: [folders objectAtIndex:i]];
if ([block isNotNull]) [blocks addObject:block];
}
if (![blocks count])
blocks = nil;
[self getTitle: &title folderType: &ft andIcon: &icon forObject: _object];
// NSLog (@"*********** title = '%@'/icon = '%@'", title, icon);
md = [UIxMailTreeBlock blockWithName: [_object nameInContainer]
title: title
iconName: icon
link: [@"../" stringByAppendingString:
[_object nameInContainer]]
isPathNode: YES
isActiveNode: YES
childBlocks: blocks];
[md setFolderType: ft];
return md;
}
- (UIxMailTreeBlock *) treeNavigationBlockForActiveNode: (id) _object
{
/*
This generates the block for the clientObject (the object which has the
focus)
*/
UIxMailTreeBlock *md;
NSMutableArray *blocks;
NSArray *folders;
NSString *title, *icon, *ft;
unsigned i, count;
// TODO: maybe we can join the two implementations, this might not be
// necessary
if ([self isRootObject:_object]) /* we are at the top */
return [self treeNavigationBlockForRootNode:_object];
if (debugBlocks) {
[self logWithFormat:@"block for active node 0x%08X<%@> - %@",
_object, NSStringFromClass([_object class]),
[_object davDisplayName]];
}
/* process child folders */
folders = [self fetchSubfoldersOfObject:_object];
count = [folders count];
blocks = [NSMutableArray arrayWithCapacity:count];
for (i = 0; i < count; i++) {
UIxMailTreeBlock *block;
block = [self treeNavigationBlockForLeafNode: [folders objectAtIndex:i]
atDepth: 0];
if ([block isNotNull]) [blocks addObject:block];
}
if ([blocks count] == 0) blocks = nil;
/* build block */
[self getTitle:&title folderType: &ft andIcon:&icon forObject:_object];
md = [UIxMailTreeBlock blockWithName: [_object nameInContainer]
title: title
iconName: icon
link: @"."
isPathNode: YES
isActiveNode: YES
childBlocks: blocks];
return md;
}
- (UIxMailTreeBlock *)
treeNavigationBlockForObject: (id) _object
withActiveChildBlock: (UIxMailTreeBlock *) _activeChildBlock
depth: (int) _depth
{
/*
Note: 'activeChildBlock' here doesn't mean that the block is the selected
folder in the tree. Its just the element which is active in the
list of subfolders.
*/
UIxMailTreeBlock *resultBlock;
NSMutableArray *blocks;
NSString *activeName;
NSArray *folders;
NSString *title, *icon, *ft;
unsigned i, count;
activeName = [_activeChildBlock valueForKey:@"name"];
/* process child folders */
folders = [self fetchSubfoldersOfObject:_object];
count = [folders count];
blocks = [NSMutableArray arrayWithCapacity:count == 0 ? 1 : count];
for (i = 0; i < count; i++) {
UIxMailTreeBlock *block;
id folder;
folder = [folders objectAtIndex:i];
block = [activeName isEqualToString:[folder nameInContainer]]
? _activeChildBlock
: [self treeNavigationBlockForLeafNode: folder
atDepth:_depth];
if ([block isNotNull]) [blocks addObject:block];
}
if ([blocks count] == 0) {
if (_activeChildBlock != nil) // if the parent has no proper fetchmethod!
[blocks addObject:_activeChildBlock];
else
blocks = nil;
}
/* build block */
[self getTitle:&title folderType: &ft andIcon:&icon forObject:_object];
resultBlock
= [UIxMailTreeBlock blockWithName: [_object nameInContainer]
title: title
iconName: icon
link:
[self treeNavigationLinkForObject: _object
atDepth: (_depth + 1)]
isPathNode:YES isActiveNode:NO
childBlocks:blocks];
/* recurse up unless we are at the root */
if ([self isRootObject:_object]) /* we are at the top */
return resultBlock;
return [self treeNavigationBlockForObject:[_object container]
withActiveChildBlock:resultBlock
depth:(_depth + 1)];
}
- (UIxMailTreeBlock *)buildNavigationNodesForObject:(id)_object {
/*
This is the top-level 'flattening' method. The _object is the active
object in the tree, that is, usually a "current folder".
The tree will show:
all subfolders of the current folder,
all parent folders of the current folder up to some root,
all siblings along the parent chain.
*/
UIxMailTreeBlock *block;
/*
This is the cursor, we create nodes below that for direct subfolders
*/
if (debugBlocks) [self logWithFormat:@"ACTIVE block ..."];
block = [self treeNavigationBlockForActiveNode:_object];
if (debugBlocks) [self logWithFormat:@" ACTIVE block: %@", block];
if ([self isRootObject:_object]) {
if (debugBlocks) [self logWithFormat:@" active block is root."];
return block;
}
/*
The following returns the root block. It calculates the chain up to the
root folder starting with the parent of the current object.
*/
if (debugBlocks) [self logWithFormat:@"ACTIVE parent block ..."];
block = [self treeNavigationBlockForObject:[_object container]
withActiveChildBlock:block
depth: 1];
if (debugBlocks) [self logWithFormat:@"done: %@", block];
return block;
}
/* tree */
- (NSArray *)rootNodes {
UIxMailTreeBlock *navNode;
if (rootNodes != nil)
return rootNodes;
navNode = [self buildNavigationNodesForObject:[self clientObject]];
if ([navNode hasChildren] && [navNode areChildrenLoaded])
rootNodes = [[navNode children] retain];
else if (navNode)
rootNodes = [[NSArray alloc] initWithObjects:&navNode count:1];
return rootNodes;
}
- (int) addNodes: (NSArray *) nodes
atSerial: (int) startSerial
forParent: (int) parent
withRootName: (NSString *) rootName
toArray: (NSMutableArray *) array
{
unsigned int count, max, currentSerial;
UIxMailTreeBlock *curNode;
NSString *fullName;
max = [nodes count];
currentSerial = startSerial;
for (count = 0; count < max; count++)
{
curNode = [nodes objectAtIndex: count];
fullName = [rootName stringByAppendingFormat: @"/%@", [curNode name]];
[curNode setName: fullName];
[curNode setSerial: currentSerial];
[curNode setParent: parent];
[array addObject: curNode];
if ([curNode hasChildren])
currentSerial = [self addNodes: [curNode children]
atSerial: currentSerial + 1
forParent: currentSerial
withRootName: fullName
toArray: array];
else
currentSerial++;
}
return currentSerial;
}
- (NSArray *) flattenedNodes
{
UIxMailTreeBlock *rootNode; // , *curNode;
id mailAccounts;
// unsigned int count, max;
if (!flattenedNodes)
{
flattenedNodes = [NSMutableArray new];
if (![[self clientObject] isKindOfClass: NSClassFromString(@"SOGoMailAccounts")])
mailAccounts = [[self clientObject] mailAccountsFolder];
else
mailAccounts = [self clientObject];
rootNode = [self fullTreeNavigationBlockForNode: mailAccounts];
[self addNodes: [rootNode children]
atSerial: 1
forParent: 0
withRootName: @""
toArray: flattenedNodes];
// max = [flattenedBlocks count];
// for (count = 0; count < max; count++)
// {
// curNode = [flattenedBlocks objectAtIndex: count];
// NSLog (@"%d: %@/%@", count, [curNode title], [curNode iconName]);
// }
}
return flattenedNodes;
}
/* notifications */
- (void) sleep
{
[item release]; item = nil;
[rootNodes release]; rootNodes = nil;
[super sleep];
}
@end /* UIxMailTree */
@implementation NSString(DotCutting)
- (NSString *)stringByCuttingOffAtDotsWhenExceedingLength:(int)_maxLength {
NSRange r, r2;
NSString *s;
int i;
if ([self length] <= _maxLength) /* if length is small, return as is */
return self;
if ((r = [self rangeOfString:@"."]).length == 0)
/* no dots in share, return even if longer than boundary */
return self;
s = self;
i = r.location + r.length;
r2 = [s rangeOfString:@"." options:NSLiteralSearch
range:NSMakeRange(i, [s length] - i)];
if (r2.length > 0) {
s = [s substringToIndex:r2.location];
if ([s length] <= _maxLength) /* if length is small, return as is */
return s;
}
/* no second dot, and the whole was too long => cut off after first */
return [s substringToIndex:r.location];
}
- (NSString *)titleForSOGoIMAP4String {
/*
eg:
guizmo.g.-.baluh.hommes.tests-montee-en-charge-ogo@\
amelie-01.ac.melanie2.i2
*/
static int CutOffLength = 16;
NSString *s;
NSRange r;
s = self;
/* check for connect strings without hostnames */
r = [s rangeOfString:@"@"];
if (r.length == 0) {
/* no login provide, just use the hostname (without domain) */
r = [s rangeOfString:@"."];
return r.length > 0 ? [s substringToIndex:r.location] : s;
}
s = [s substringToIndex:r.location];
/* check for shares */
r = [s rangeOfString:@".-."];
if (r.length > 0) {
/* eg: 'baluh.hommes.tests-montee-en-charge-ogo' */
s = [s substringFromIndex:(r.location + r.length)];
return [s stringByCuttingOffAtDotsWhenExceedingLength:CutOffLength];
}
/* just the login name, possibly long (test.et.di.cete-lyon) */
return [s stringByCuttingOffAtDotsWhenExceedingLength:CutOffLength];
}
@end /* NSString(DotCutting) */

View File

@@ -1,99 +0,0 @@
/*
Copyright (C) 2004-2005 SKYRIX Software AG
This file is part of OpenGroupware.org.
OGo is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
OGo is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public
License along with OGo; see the file COPYING. If not, write to the
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
#ifndef __UIxMailTreeBlock_H__
#define __UIxMailTreeBlock_H__
#import <Foundation/NSObject.h>
@class NSString, NSArray;
/*
UIxMailTreeBlock
A helper object for UIxMailTree.
*/
extern id UIxMailTreeHasChildrenMarker;
@interface UIxMailTreeBlock : NSObject
{
NSString *name;
NSString *title;
NSString *link;
NSArray *blocks;
NSString *iconName;
NSString *folderType;
int serial;
int parent;
struct {
int isPath:1;
int isActive:1;
int reserved:30;
} flags;
}
+ (id) blockWithName: (NSString *)_n
title: (NSString *)_t
iconName: (NSString *)_i
link: (NSString *)_link
isPathNode: (BOOL)_isPath
isActiveNode: (BOOL)_isActive
childBlocks: (NSArray *)_blocks;
- (id)initWithName: (NSString *)_n
title: (NSString *)_t
iconName: (NSString *)_i
link: (NSString *)_link
isPathNode: (BOOL)_isPath
isActiveNode: (BOOL)_isActive
childBlocks: (NSArray *)_blocks;
/* accessors */
- (BOOL) hasChildren;
- (BOOL) areChildrenLoaded;
- (NSArray *) children;
- (void) setName: (NSString *) newName;
- (NSString *) name;
- (void) setSerial: (int) newSerial;
- (int) serial;
- (void) setParent: (int) newParent;
- (int) parent;
- (void) setFolderType: (NSString *) newFolderType;
- (NSString *) folderType;
- (NSString *) serialAsString;
- (NSString *) parentAsString;
- (NSString *) title;
- (NSString *) link;
- (NSString *) iconName;
- (NSString *) folderMenuId;
@end
#endif /* __UIxMailTreeBlock_H__ */

View File

@@ -1,223 +0,0 @@
/*
Copyright (C) 2004-2005 SKYRIX Software AG
This file is part of OpenGroupware.org.
OGo is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
OGo is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public
License along with OGo; see the file COPYING. If not, write to the
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
#import "UIxMailTreeBlock.h"
#import "common.h"
@implementation UIxMailTreeBlock
id UIxMailTreeHasChildrenMarker = nil;
+ (void) initialize
{
// TODO: needs to be an array because the WETreeView requires a
// children array
UIxMailTreeHasChildrenMarker =
[[NSArray alloc] initWithObjects:@"FAKE", nil];
}
+ (id) blockWithName: (NSString *) _name
title: (NSString *) _title
iconName: (NSString *) _icon
link: (NSString *) _link
isPathNode: (BOOL) _isPath
isActiveNode: (BOOL) _isActive
childBlocks: (NSArray *) _blocks
{
UIxMailTreeBlock *block;
block = [[self alloc] initWithName:_name
title:_title
iconName:_icon
link:_link
isPathNode:_isPath
isActiveNode:_isActive
childBlocks:_blocks];
return [block autorelease];
}
- (id) initWithName: (NSString *) _name
title: (NSString *) _title
iconName: (NSString *) _icon
link: (NSString *) _link
isPathNode: (BOOL) _isPath
isActiveNode: (BOOL) _isActive
childBlocks: (NSArray *) _blocks
{
if ((self = [self init]))
{
self->name = [_name copy];
self->title = [_title copy];
self->iconName = [_icon copy];
self->link = [_link copy];
self->blocks = [_blocks retain];
self->flags.isPath = _isPath ? 1 : 0;
self->flags.isActive = _isActive ? 1 : 0;
}
return self;
}
- (void) dealloc
{
[self->iconName release];
[self->blocks release];
[self->name release];
[self->title release];
[self->link release];
[super dealloc];
}
/* accessors */
- (NSString *) name
{
return self->name;
}
- (void) setName: (NSString *) newName
{
if (name)
[name release];
name = [newName copy];
if (name)
[name retain];
}
- (NSString *) title
{
return self->title;
}
- (NSString *) link
{
return self->link;
}
- (NSString *) iconName
{
return self->iconName;
}
- (BOOL) hasChildren
{
if (self->blocks == UIxMailTreeHasChildrenMarker)
return YES;
return [self->blocks count] > 0 ? YES : NO;
}
- (BOOL) areChildrenLoaded
{
return self->blocks != UIxMailTreeHasChildrenMarker ? YES : NO;
}
- (NSArray *) children
{
if (self->blocks == UIxMailTreeHasChildrenMarker)
// TODO: print a warning
return self->blocks;
return self->blocks;
}
- (BOOL) isPathNode
{
return self->flags.isPath ? YES : NO;
}
- (BOOL) isActiveNode
{
return self->flags.isActive ? YES : NO;
}
/* description */
- (void) appendAttributesToDescription: (NSMutableString *) _ms
{
if (self->name != nil) [_ms appendFormat:@" name='%@'", self->name];
if (self->title != nil) [_ms appendFormat:@" title='%@'", self->title];
if ([self isPathNode]) [_ms appendString:@" path"];
if ([self isActiveNode]) [_ms appendString:@" active"];
if (self->blocks == UIxMailTreeHasChildrenMarker)
[_ms appendString:@" has-children"];
else if ([self->blocks count] > 0)
[_ms appendFormat:@" children=%@", self->blocks];
}
- (NSString *) description
{
NSMutableString *ms;
ms = [NSMutableString stringWithCapacity:64];
[ms appendFormat:@"<0x%08X[%@]:", self, NSStringFromClass([self class])];
[self appendAttributesToDescription:ms];
[ms appendString:@">"];
return ms;
}
- (void) setSerial: (int) newSerial
{
serial = newSerial;
}
- (int) serial
{
return serial;
}
- (NSString *) serialAsString
{
return [NSString stringWithFormat: @"%d", serial];
}
- (void) setParent: (int) newParent
{
parent = newParent;
}
- (int) parent
{
return parent;
}
- (void) setFolderType: (NSString *) newFolderType
{
folderType = newFolderType;
}
- (NSString *) folderType
{
return folderType;
}
- (NSString *) parentAsString
{
return [NSString stringWithFormat: @"%d", parent];
}
- (NSString *) folderMenuId
{
return [NSString stringWithFormat: @"__wox_submenu_%d-%d", parent, serial];
}
@end /* UIxMailTreeBlock */

View File

@@ -1,53 +0,0 @@
/* UIxMailTreeBlockJS.h - this file is part of $PROJECT_NAME_HERE$
*
* Copyright (C) 2006 Inverse groupe conseil
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
* 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
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef UIXMAILTREEBLOCKJS_H
#define UIXMAILTREEBLOCKJS_H
#import <SOGoUI/UIxComponent.h>
#import "common.h"
@class NSString;
@class UIxMailTreeBlock;
@interface UIxMailTreeBlockJS : UIxComponent
{
UIxMailTreeBlock *item;
NSString *treeObjectName;
}
- (void) setItem: (UIxMailTreeBlock *) newItem;
- (UIxMailTreeBlock *) item;
- (NSString *) iconName;
- (void) setTreeObjectName: (NSString *) newName;
- (NSString *) treeObjectName;
- (BOOL) isAccount;
- (BOOL) isInbox;
- (BOOL) isTrash;
@end
#endif /* UIXMAILTREEBLOCKJS_H */

View File

@@ -1,113 +0,0 @@
/* UIxMailTreeBlockJS.m - this file is part of $PROJECT_NAME_HERE$
*
* Copyright (C) 2006 Inverse groupe conseil
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
* 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
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#import "UIxMailTreeBlockJS.h"
#import "Common/UIxPageFrame.h"
@implementation UIxMailTreeBlockJS
- (id) init
{
if ((self = [super init]))
{
item = nil;
}
return self;
}
- (void) setItem: (UIxMailTreeBlock *) newItem
{
item = newItem;
}
- (UIxMailTreeBlock *) item
{
return item;
}
- (WOResourceManager *) resourceManager
{
WOResourceManager *resourceManager;
id c;
resourceManager = nil;
c = self;
while (!resourceManager
&& c)
if ([c respondsToSelector: @selector(pageResourceManager)])
resourceManager = [c pageResourceManager];
else
c = [c parent];
return resourceManager;
}
- (NSString *) iconName
{
WOResourceManager *resourceManager;
NSString *iconName, *rsrcIconName;
iconName = [item iconName];
if ([iconName length] > 0)
{
resourceManager = [self resourceManager];
rsrcIconName = [resourceManager urlForResourceNamed: iconName
inFramework: nil
languages: nil
request: [[self context] request]];
}
else
rsrcIconName = nil;
return rsrcIconName;
}
- (void) setTreeObjectName: (NSString *) newName
{
treeObjectName = newName;
}
- (NSString *) treeObjectName
{
return treeObjectName;
}
- (BOOL) isAccount
{
return ([item parent] == 0);
}
- (BOOL) isInbox
{
return ([[item name] isEqualToString: @"INBOX"]);
}
- (BOOL) isTrash
{
return NO;
}
@end

View File

@@ -267,7 +267,7 @@
};
mailboxes = {
protectedBy = "View";
pageName = "UIxMailAccountView";
actionClass = "UIxMailAccountActions";
actionName = "listMailboxes";
};
};

View File

@@ -2,12 +2,17 @@
<var:component xmlns="http://www.w3.org/1999/xhtml"
xmlns:var="http://www.skyrix.com/od/binding"
xmlns:const="http://www.skyrix.com/od/constant"
xmlns:uix="OGo:uix"
xmlns:rsrc="OGo:url"
xmlns:label="OGo:label"
className="UIxPageFrame"
title="title"
popup="isPopup"
>
<script type="text/javascript" rsrc:src="dtree.js"><!-- space --></script>
<script type="text/javascript" rsrc:src="MailerUI+dTree.js"><!-- space --></script>
<script type="text/javascript">
var mailAccounts = '<var:string value="mailAccounts" const:escapeHTML="NO"/>'.evalJSON(true);
</script>
<div class="menu" id="accountIconMenu">
<ul>
<li><var:string label:value="Subscribe..." /></li>
@@ -127,13 +132,6 @@
</ul>
</div>
<var:component
className="UIxMailFolderMenu"
const:menuId="mailboxes-menu"
const:parentMenu="0"
rootClassName="treeRootClassName"
const:treeFolderAction="view" />
<div class="menu" id="mark-menu">
<ul id="">
<li><var:string label:value="As Read" /></li>
@@ -151,12 +149,9 @@
<div id="leftPanel">
<div class="titlediv"><var:string label:value="Folders" /></div>
<var:component className="UIxMailTree"
rootClassName="treeRootClassName"
const:treeFolderAction="view"
/>
<div id="folderTreeContent"><!-- space --></div>
</div>
<div class="dragHandle" id="verticalDragHandle"><!-- space --></div>
<div id="rightPanel">
@@ -165,9 +160,6 @@
<div id="mailboxContent"><!-- space --></div>
<div class="dragHandle" id="rightDragHandle"><!-- space --></div>
<div id="messageContent"><!-- space --></div>
<script type="text/javascript">
initMailboxSelection('<var:string value="mailFolderName" />');
</script>
</div>
<var:string value="errorAlertJavaScript" const:escapeHTML="NO" />