Note: If you change something, give your change a number (1), add number to
      changed place in text and add a new entry to CHANGES section below.
      E.g.: bback on ...: changed processing logic (3)

-------------------------------------------------------------------------------
CHANGED:
---------

-
- bback on 2003/06/04: inital version
----------------------------------------------------

-> each new thread gets a unique id
-> each message gets a unique id
-> thread xml files are in folder keypool/boardname/ with name: rootmsgdate+threadid.xml.zip


Processing of incoming files as following (in order):

(note: i chosed to save the marker files (isreceived+isnew) to disk (only 0 bytes files, or
    if really needed with some content (id,verified,...)).
    I think this is the best way to store the markers because its at least as transaction save
    as the underlying filesystem. If we store to existing files (e.g. the local xml file wich
    holds the wohle thread), we always write to a temp-file first, then rename the original file (.old),
    rename the new file and then remove the old file. This should save enough even for system crash
    during the processing.
)
-------------------------------------------

- request files from freenet by index, name like boardname-date-index
- store files to folder keypool/boardname/received for processing

- if a requested file is received, create message processing thread (not started yet)
- enqueue the thread into a fifo queue
- a working thread monitors this queue and starts the threads one after the next per board,
   because the following processing (gui scanning+update of xml) should be synchronized by board

THREAD START (gets filename of received file):

- read received file
- extract sign + check against local identities/buddies

-> to define: what to do with ENCRYPTED messages? How to save them in XML thread tree, ... ???

- if OK, parse message

- open local thread xml file if existing, else use the received xml file as new local thread xml file
- (if thread is existing):
- merge the local+received message xml trees and remember the local new messages
- save the merged thread xml file back to local disk
- (if thread is new):
- read new threads messages and remember them
- save the new thread xml file back to local disk

- write the isnew-file with name:
    keypool/board/newmsg/date_threadid_messageid
- notify gui about new messages (simply give the parsed xml tree to gui + filenames of isnew,
   gui will update its thread tree itself and mark the new messages
   (and of course keeps marked the already existing msg)
- later on next startup the GUI will check for the isnew-files to mark new messages.
  The gui will delete this file if a message is choosed by the user.
  Planned:
    The user will have the possibility to mark read messages as unread.
    Hence we should rename the 'New messages' to 'Unread messages' as in newsgroup tools

- finally (end of transaction) write the isreceived-file,
     filename = boarddir/date/boardname-date-index... (same name as received file)
     (maybe include something in file, otherwise only a 0 byte file is needed
      (only for tracking wich index was downloaded))
  The isreceived file is used by download thread to know about already downloaded files,
  and for upload thread to know about the highest index for today

- delete the received file (all data is stored in local thread xml file, not needed any longer)

THREAD END

... end processing continues with next received file for board
