Hi Vincent,
This is big message, you can find here answers to questions from
previous your emails, and other my thoughts.
=Context menu=
Regarding right-click context menu with subfolder creation, renaming
and folder deletion, I found that menu! :) I thought that this
functionality is on the site
kairos.smartmobili.com, but now I figured
out, that it is only exists in development version or at new location
(
http://bifrost.smartmobili.com/kairos/capp).
=Folder creation=
You asked me to implement folder creation. I made it. It mades folders
in ROOT as you suggested in last email (so no subfolders creation).
First, i made thoughts what we need except "folder creation at server
side" to make folder creation at all. This should be also
implementation at client side (you already showed parts of code for
mailsourceviewController.j) and also folder renaming, because after
folder creation in UI, we starting to edit its name, and it should
reflect changes at imap server.
Next, I investigated, how it was supposed to be in current
realization. I found all places in code and "TODO" marks in comments.
I found already existed code for mail folder creation (it is still
named as box not folder) : createMailbox function in SMMailAccount.j.
But full system was not done, e.g. folders only created in UI and not
at server. Here I describe how it works (here is events flow
described): first, is called code addMailbox() in
MailSourceViewController.j when user click button or menu item to add
folder. That code call createMailbox() function in SMMailAccount.j.
There is comment says that it really do nothing, because we not yet
set name to mailbox (it is OK). Next, UI switch to edit mode, and user
should enter the name for mail folder. After that this function
called:
- (void)outlineView:(CPOutlineView)anOutlineView setObjectValue:
(id)aValue forTableColumn:(CPTableColumn) in
MailSourceViewController.j
which calls "renameTo" function in SMMailbox.j. And there is comments
with "TODO" meaning that it is not implemented. There is commended
call to server function [imapServer renameFolder] which not
implemented. Bellow there in save() function we see commented call to
[imapServer createFolder] which also is not implemented.
So the end of this calling chain is undone. This is what I have
implemented. Function calls for [imapServer renameFolder] and
[imapServer createFolder] was commented but I disliked location of
that calls. "createFolder" call located in "save" function which
called for SMRemoteObject, so it will call createFolder each time when
object is just "saved"? This is not good (I'm not sure how it works,
this is part of cardano code i think). So, I made at server function
"renameOrCreateFolder". It try to rename folder if it exists, or it
will create new folder if previous one is not exists. Now I call this
function each time when editing folder name in UI is ended (e.g. when
renameTo function is called).
=How to test renameOrCreateFolder=
So, In last my commit I made this renameOrCreateFolder function. I
tested both, folder creation and folder renaming is works and after
relaunching browser folders is there (saved). Also note that we should
turn off cache to work. Without turning off, it will download list of
folders from cache and not from IMAP server so you will not see
changes in UI when using cache. But without cache it works slow.
Note: it very slow responds cause of current IMAP realization without
pools.
I suggest you to start server in debugger (Eclipse), and set
breakpoint in "renameOrCreateFolder" function. Then run browser, and
after creating and naming folder, wait. Wait when you will hit
breakpoint. For me it takes around 1-2 minutes. After that you can
continue run code in debugger. It will create folder at IMAP server.
Now you can reload web app in browser, and you will see that folder is
still there, re-downloaded from IMAP server, as expected.
=IMAP, architecture and pools=
I made debugging of "connect" function in ImapScala. Seems that during
just usual login to web app via browser, it makes 2-3 connections to
IMAP. This is what I talking about IMAP pools at server. With pool we
can have only 1 connection for 1 user to IMAP and keep it opened. This
is more efficient for resources at our server, and at imap server(s).
But we should think more deeply about imap and pools architecture. As
I said in previous messages, we should be careful with connections
count to IMAP server, to not over flood it. Even just 1 IMAP
connection per user is a huge count if we talking about 1000 users
simultaneously.
So currently "renameOrCreateFolder" function, and other functions is
responds slow. This implementation is temporary, later when all new
IMAP architecture will be done, we need use "IMAP pool" class (or
something like that) to achieve any IMAP-related functions. It will
work faster, because pool should keep opened connection to IMAP.
Currently we open NEW connection to IMAP right here in any our
function (like "renameOrCreateFolder" function), so user feel some
delay (in case of "renameOrCreateFolder" this is big delay), and also
IMAP server will receive huge count of connections.
=Scala=
I don't feel any problems with scala yet, so currently I feel
comfortable with it. I don't think that language is matters here. I
don't like current realization of ImapService.scala, because it have
useless cache, it open huge count of IMAP connections and etc (so at
end it responds slow for user). But it not depends on language.
=Naming=
I agree with you that Mailbox is not right name for "folder". So I
agree, that it can be renamed from Mailbox to MailFolder or something
like that.
=Syntax and conventions=
Regarding syntax and code styles and conventions. I think in Objective-
J we should use same style as in Objective-C by Apple, so we can refer
to Apple documentation here. So local variables is as is, and member
variables can be as is, or can be accessed via self.nameOfVariable
(e.g. self is added), and member properties is accessed via accessor
methods via sending message e.g. [self nameOfVariable] (which actually
calls getnameOfVariable). Current kairos code is OK for me.
Here is more info:
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingIvarsAndTypes.html#//apple_ref/doc/uid/20001284-BAJGIIJE
=IMAP libraries=
Perhaps later we can investigate, choose between different libraries
and etc. But currently this is not matters. Base functionality is
exists in current standard javamail. It is enough currently. All slow
responding of system is not because of library, but because it is used
wrong (e.g. call connect() and open many connections).