* rework login screen to utilize more modern templating
[citadel.git] / webcit / webcit.h
index 4509ecb1ffa3a26fe3b116afcfbe11249d42a56a..f431ac9e7f752e23c4f1bbe68707a9195b893807 100644 (file)
@@ -260,7 +260,13 @@ struct roomlisting {
 
 #define TYPE_STR   1
 #define TYPE_LONG  2
+#define TYPE_PREFSTR 3
+#define TYPE_PREFINT 4
+#define TYPE_GETTEXT 5
+#define TYPE_BSTR 6
 #define MAXPARAM  20
+
+
 typedef struct _TemplateParam {
        const char *Start;
        int Type;
@@ -313,6 +319,8 @@ typedef struct _wcsubst {
 #define CTX_USERLIST 8
 #define CTX_MAILSUM 9
 #define CTX_MIME_ATACH 10
+#define CTX_ATT 11
+#define CTX_STRBUF 12
 
 void RegisterNS(const char *NSName, long len, 
                int nMinArgs, 
@@ -323,6 +331,7 @@ void RegisterNS(const char *NSName, long len,
 
 typedef int (*WCConditionalFunc)(WCTemplateToken *Token, void *Context, int ContextType);
 typedef struct _ConditionalStruct {
+       const char *PlainName;
        int nParams;
        int ContextRequired;
        WCConditionalFunc CondF;
@@ -347,6 +356,12 @@ void RegisterITERATOR(const char *Name, long len, /* Our identifier */
                      int XPectContextType);         /* which context do we expct to be called in? */
 #define RegisterIterator(a, b, c, d, e, f, g, h) RegisterITERATOR(a, sizeof(a)-1, b, c, d, e, f, g, h)
 
+void GetTemplateTokenString(WCTemplateToken *Tokens,
+                           int N, 
+                           const char **Value, 
+                           long *len);
+
+
 void SVPut(char *keyname, size_t keylen, int keytype, char *Data);
 #define svput(a, b, c) SVPut(a, sizeof(a) - 1, b, c)
 void SVPutLong(char *keyname, size_t keylen, long Data);
@@ -367,6 +382,11 @@ void url_do_template(void);
 int CompareSubstToToken(TemplateParam *ParamToCompare, TemplateParam *ParamToLookup);
 int CompareSubstToStrBuf(StrBuf *Compare, TemplateParam *ParamToLookup);
 
+void StrBufAppendTemplate(StrBuf *Target, 
+                         int nArgs, 
+                         WCTemplateToken *Tokens,
+                         void *Context, int ContextType,
+                         const StrBuf *Source, int FormatTypeIndex);
 
 
 
@@ -385,19 +405,20 @@ enum {
 /*
  * \brief mail attachment ???
  */
-struct wc_attachment {
-       struct wc_attachment *next;/* pointer to next in list */
+typedef struct _wc_attachment {
        size_t length;                     /* length of the contenttype */
-       char content_type[SIZ];    /* the content itself ???*/
-       char filename[SIZ];                /* the filename hooked to this content ??? */
+       StrBuf *content_type;      /* the content itself ???*/
+       StrBuf *filename;                  /* the filename hooked to this content ??? */
        char *data;                /* the data pool; aka this content */
        long lvalue;               /* if we put a long... */
-};
+} wc_attachment;
+void free_attachment(void *vattach);
 
 
 typedef struct wc_mime_attachment wc_mime_attachment;
 typedef void (*RenderMimeFunc)(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset);
 struct wc_mime_attachment {
+       int level;
        StrBuf *Name;
        StrBuf *FileName;
        StrBuf *PartNum;
@@ -437,6 +458,7 @@ typedef struct _message_summary {
        StrBuf *Room;
        StrBuf *Rfca;
        StrBuf *OtherNode;
+       const StrBuf *PartNum;
 
        HashList *Attachments;  /**< list of Accachments */
        HashList *Submessages;
@@ -449,17 +471,13 @@ typedef struct _message_summary {
 
 
        /** The mime part of the message */
-       wc_mime_attachment MsgBody;
-
-
-       /** Referencces; don't neeed to be freed: */
-       wc_mime_attachment *cal_partnum_ref;
-       wc_mime_attachment *vcard_partnum_ref;
+       wc_mime_attachment *MsgBody;
 } message_summary;
 void DestroyMessageSummary(void *vMsg);
 
 typedef void (*ExamineMsgHeaderFunc)(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset);
 
+void evaluate_mime_part(message_summary *Msg, wc_mime_attachment *Mime);
 
 
 
@@ -570,7 +588,7 @@ struct wcsession {
        char http_host[512];                    /**< HTTP Host: header */
        HashList *hash_prefs;                   /**< WebCit preferences for this user */
        HashList *disp_cal_items;               /**< sorted list of calendar items; startdate is the sort criteria. */
-       struct wc_attachment *first_attachment; /**< linked list of attachments for 'enter message' */
+       HashList *attachments;                  /**< list of attachments for 'enter message' */
        char last_chat_user[256];               /**< ??? todo */
        char ImportantMessage[SIZ];             /**< ??? todo */
        int ctdl_pid;                           /**< Session ID on the Citadel server */
@@ -671,7 +689,7 @@ extern HashList *LocalTemplateCache;
 extern HashList *GlobalNS;
 extern HashList *Iterators;
 extern HashList *ZoneHash;
-extern HashList *Contitionals;
+extern HashList *Conditionals;
 extern HashList *MsgHeaderHandler;
 extern HashList *MimeRenderHandler;
 
@@ -689,7 +707,7 @@ void cookie_to_stuff(StrBuf *cookie, int *session,
 void locate_host(char *, int);
 void become_logged_in(char *, char *, char *);
 void openid_manual_create(void);
-void display_login(char *mesg);
+void display_login();
 void display_openids(void);
 void do_welcome(void);
 void do_logout(void);
@@ -780,7 +798,7 @@ void dump_vars(void);
 void embed_main_menu(void);
 void serv_read(char *buf, int bytes);
 void readloop(char *oper);
-void read_message(long msgnum, int printable_view, char *section);
+int  read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, int printable_view, const StrBuf *section);
 void do_addrbook_view(addrbookent *addrbook, int num_ab);
 void display_vcard(StrBuf *Target, const char *vcard_source, char alpha, int full, char *storename, long msgnum);
 void text_to_server(char *ptr);