Back to index

enigmail  1.4.3
mimedummy.cpp
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public
00005  * License Version 1.1 (the "MPL"); you may not use this file
00006  * except in compliance with the MPL. You may obtain a copy of
00007  * the MPL at http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the MPL is distributed on an "AS
00010  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
00011  * implied. See the MPL for the specific language governing
00012  * rights and limitations under the MPL.
00013  *
00014  * The Original Code is Enigmail.
00015  *
00016  * The Initial Developer of the Original Code is Ramalingam Saravanan.
00017  * Portions created by Ramalingam Saravanan <sarava@sarava.net> are
00018  * Copyright (C) 2002 Ramalingam Saravanan. All Rights Reserved.
00019  *
00020  * Contributor(s):
00021  * Patrick Brunschwig <patrick@mozilla-enigmail.org>
00022  *
00023  * Alternatively, the contents of this file may be used under the terms of
00024  * either the GNU General Public License Version 2 or later (the "GPL"), or
00025  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00026  * in which case the provisions of the GPL or the LGPL are applicable instead
00027  * of those above. If you wish to allow use of your version of this file only
00028  * under the terms of either the GPL or the LGPL, and not to allow others to
00029  * use your version of this file under the terms of the MPL, indicate your
00030  * decision by deleting the provisions above and replace them with the notice
00031  * and other provisions required by the GPL or the LGPL. If you do not delete
00032  * the provisions above, a recipient may use your version of this file under
00033  * the terms of any one of the MPL, the GPL or the LGPL.
00034  * ***** END LICENSE BLOCK ***** */
00035 
00036 #define MOZILLA_INTERNAL_API
00037 #include "mimedummy.h"
00038 #include "nsEnigMimeService.h"
00039 
00040 MimeEncryptedClass* mimeEncryptedClassP = NULL;
00041 
00042 /* Set superclass to NULL and initialize by hand later */
00043 MimeDefClass(MimeDummy, MimeDummyClass, mimeDummyClass,
00044              NULL);
00045 
00046 static int MimeDummy_initialize (MimeObject *);
00047 static void MimeDummy_finalize (MimeObject *);
00048 static int MimeDummy_parse_begin (MimeObject *);
00049 static int MimeDummy_parse_buffer (const char *, PRInt32, MimeObject *);
00050 static int MimeDummy_parse_line (const char *, PRInt32, MimeObject *);
00051 static int MimeDummy_parse_eof (MimeObject *, EMBool);
00052 static int MimeDummy_parse_end (MimeObject *, EMBool);
00053 static int MimeDummy_add_child (MimeObject *, MimeObject *);
00054 
00055 static int
00056 MimeDummyClassInitialize(MimeDummyClass *clazz)
00057 {
00058   MimeObjectClass    *oclass = (MimeObjectClass *)    clazz;
00059   MimeContainerClass *cclass = (MimeContainerClass *) clazz;
00060 
00061   PR_ASSERT(!oclass->class_initialized);
00062   oclass->initialize   = MimeDummy_initialize;
00063   oclass->finalize     = MimeDummy_finalize;
00064   oclass->parse_begin  = MimeDummy_parse_begin;
00065   oclass->parse_buffer = MimeDummy_parse_buffer;
00066   oclass->parse_line   = MimeDummy_parse_line;
00067   oclass->parse_eof    = MimeDummy_parse_eof;
00068   oclass->parse_end    = MimeDummy_parse_end;
00069 
00070   cclass->add_child    = MimeDummy_add_child;
00071 
00072   return 0;
00073 }
00074 
00075 
00076 static int
00077 MimeDummy_initialize(MimeObject *obj)
00078 {
00079   MimeObjectClass *clazz = obj->clazz;
00080 
00081   fprintf(stderr, "MimeDummy_initialize: class_name=%s\n", clazz->class_name);
00082 
00083   return 0;
00084 }
00085 
00086 
00087 static int
00088 MimeDummy_parse_begin(MimeObject *obj)
00089 {
00090   fprintf(stderr, "MimeDummy_parse_begin:\n");
00091 
00092   MimeObject *parent = obj->parent;
00093 
00094   MimeContainer* container = (MimeContainer *) parent;
00095 
00096   if (container) {
00097     PRInt32 nchildren = container->nchildren;
00098     fprintf(stderr, "MimeDummy_parse_begin: nchildren=%d\n",nchildren );
00099 
00100     if (nchildren == 2) {
00101       MimeObject* sibling = *(container->children);
00102       MimeObjectClass *clazz = sibling->clazz;
00103 
00104       fprintf(stderr, "MimeDummy_parse_begin: sibling class_name=%s\n", clazz->class_name);
00105       MimeObjectClass *superclazz = clazz->superclass;
00106 
00107       if (superclazz) {
00108         fprintf(stderr, "MimeDummy_parse_begin: sibling superclass_name=%s\n", superclazz->class_name);
00109 
00110         if (!PL_strcasecmp(superclazz->class_name, "MimeEncrypted")) {
00111           // mimeEncryptedClass
00112           fprintf(stderr, "MimeDummy_parse_begin: found MimeEncrypted\n");
00113 
00114           mimeEncryptedClassP = (MimeEncryptedClass *) superclazz;
00115           MimeObjectClass* objClass = (MimeObjectClass*) &mimeEncryptedEnigClass;
00116           objClass->superclass = (MimeObjectClass *) superclazz;
00117 
00118           nsresult rv;
00119           nsCOMPtr<nsIEnigMimeService> enigMimeService = do_GetService(NS_ENIGMIMESERVICE_CONTRACTID, &rv);
00120           if (NS_SUCCEEDED(rv)) {
00121             enigMimeService->Init();
00122           }
00123 
00124         }
00125       }
00126 
00127     }
00128 
00129   }
00130 
00131   return 0;
00132 }
00133 
00134 
00135 static int
00136 MimeDummy_parse_buffer(const char *buffer, PRInt32 size, MimeObject *obj)
00137 {
00138   return 0;
00139 }
00140 
00141 
00142 static int
00143 MimeDummy_parse_line(const char *line, PRInt32 length, MimeObject *obj)
00144 {
00145   return 0;
00146 }
00147 
00148 static int
00149 MimeDummy_parse_eof(MimeObject *obj, EMBool abort_p)
00150 {
00151   return 0;
00152 }
00153 
00154 
00155 static int
00156 MimeDummy_parse_end(MimeObject *obj, EMBool abort_p)
00157 {
00158   return 0;
00159 }
00160 
00161 
00162 static void
00163 MimeDummy_finalize(MimeObject *obj)
00164 {
00165 }
00166 
00167 static int
00168 MimeDummy_add_child(MimeObject *parent, MimeObject *child)
00169 {
00170   MimeContainer *cont = (MimeContainer *) parent;
00171   if (!parent || !child) return -1;
00172 
00173   /* Encryption containers can only have one child. */
00174   if (cont->nchildren != 0) return -1;
00175 
00176   return ((MimeContainerClass*)mimeContainerClassP)->add_child(parent, child);
00177 }