File: Service_Calendar.cc

package info (click to toggle)
postman 2.0-9
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 8,036 kB
  • ctags: 3,078
  • sloc: cpp: 31,131; ansic: 1,948; sh: 787; makefile: 285
file content (318 lines) | stat: -rw-r--r-- 11,246 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
/*                              
Service_Calendar.cc
*/

#include "Service_Calendar.h"
#include "DateTimeUtils.h"

extern Language *L;
extern Configuration *Conf;
extern CCLIENT *cclient;
extern Skin *skin;

bool Service_Calendar_Initialized = false;
int workingYear, workingMonth, workingDay;
bool BeginWeekOnSunday = false;

class HTMLPages: public HTMLBasic
  {
  private:
    void PrintStatusLine_Calendar (const char *user, UserOptions *uo, bool displayClock, const char *mailboxname);
    void BotoneraComun_Calendar (int cmdactual, const char *lang, const char *user, const char *connid, UserOptions *uo);
  public:
    void PrintCalendarYearShow (TProgData *pd);    
    void PrintCalendarMonthShow (TProgData *pd);    
    void PrintCalendarWeekShow (TProgData *pd);
    void PrintCalendarDayShow (TProgData *pd);    
    void PrintCalendarEventsShow (TProgData *pd);        
    };

void HTMLPages::PrintStatusLine_Calendar (const char *user, UserOptions *uo, bool displayClock, const char *mailboxname)
  {
  WRITE ("<TABLE width=\"100%%\">\n<TR>\n");
  if (FileExists (FILE_FOR_NO_ACCEPT_NEW_CONNS) == true)
    {
    TBuffer amsg;
    GetBufferFromFile (FILE_FOR_NO_ACCEPT_NEW_CONNS, amsg, CMAXBUFFER);
    WRITE ("<TD align=left><B><FONT color=\"#FF0000\"><BLINK>%s</BLINK></FONT></B></TD>\n<TD align=right><B><FONT size=2 color=\"%s\">%s: %s@%s (%s)</FONT></B></TD>\n",
              amsg, skin->getSkinAtribProp("COLOR_FONT_STATUSLINE"), 
              L->get(L_USER), user, uo->getImapServer(), 
              mailboxname);
    }
  else
    {
    if (cclient->getError () == false)
      {
      WRITE ("<TD align=left><B>%s</B></TD>\n<TD align=right><B><FONT size=%d face=\"%s\" color=\"%s\">%s: %s@%s (%s)</FONT></B></TD>\n",
             uo->getStatusLine(), skin->getSkinAtribPropI("FONT_STATUS_SIZE"), skin->getSkinAtribProp("FONT_STATUS"), skin->getSkinAtribProp("COLOR_FONT_STATUSLINE"), 
             L->get(L_USER), user, uo->getImapServer(), 
             mailboxname);
      }
    else
      {
      WRITE ("<TD align=left><B>%s</B></TD>\n<TD align=right><B><FONT size=%d face=\"%s\" color=\"%s\">%s: %s@%s (%s)</FONT></B></TD>\n",
             cclient->getErrorString(), skin->getSkinAtribPropI("FONT_STATUS_SIZE"), skin->getSkinAtribProp("FONT_STATUS"), skin->getSkinAtribProp("COLOR_FONT_STATUSLINE"), 
             L->get(L_USER), user, uo->getImapServer(), 
             mailboxname);
      }  
    }
  
  //Only is seen in IE4+/N6+
  if ((displayClock == true) && (uo->get_use_javascript() == true) && (uo->getShowClock() == true))
    {        
    WRITE ("<TD width=\"1%%\" align=right>");  
    JavaScript (DEF_JavaScriptIDClock);    
    JavaScript (DEF_JavaScriptClock);
    WRITE ("</TD>"); 
    }

  WRITE ("\n</TR></TABLE>\n");
  }

void HTMLPages::BotoneraComun_Calendar (int cmdactual, const char *lang, const char *user, const char *connid, UserOptions *uo)
  {
  long actualpos, totalmsgs;
  int validator, pageid;
  
  actualpos = uo->getCurrentPosition();
  totalmsgs = uo->getTotalMsgs();
  validator = uo->getValidator();
  pageid    = uo->getPageId ();
  
  BeginTable (0, 0, 0, 100);
    BeginTR(skin->getSkinAtribProp("COLOR_BGBOTONERA"));
    
      //BUTTON BACK  
      BeginTD (1, skin->getSkinAtribProp("FONT_MAIN"), skin->getSkinAtribPropI("FONT_BOTONERA_SIZE"), "center");        
      WRITE ("%s", uo->getLastStringCmd(cmdactual, lang, connid, true));                   
      Image (skin->getI(L_BACK), L->get(ALT_BACK), skin->getISize()); 
      if (skin->getDisplayButtonLabels()) {WRITE (" %s\n", L->get(ALT_BACK));}
      WRITE ("</A>");
      EndTD();   

      //SPACE 
      EmptyCellx2();

      //BUTTON ROOT      
      BeginTD (1, skin->getSkinAtribProp("FONT_MAIN"), skin->getSkinAtribPropI("FONT_BOTONERA_SIZE"), "center");
      WRITE ("<A HREF=\"%s/%s/root/noop/%s/%s/%s/%d/%d/%d/%ld/\">", PATH_CGI, SERVICE_MAIN, lang, user, connid, uo->getValidator(),
         uo->getPageId(), uo->getLastCmd(), uo->getCurrentPosition());
      Image (skin->getI(L_ROOT), L->get(ALT_ROOT), skin->getISize());
      if (skin->getDisplayButtonLabels()) {WRITE (" %s\n", L->get(ALT_ROOT));}
      WRITE ("</A>");
      EndTD();   

      //SPACE 
      EmptyCellx2();
      //BUTTON HELP   
      BeginTD (1, skin->getSkinAtribProp("FONT_MAIN"), skin->getSkinAtribPropI("FONT_BOTONERA_SIZE"), "center");
      switch (cmdactual)
        {
        case CMD_CALENDAR_MONTH_SHOW: 
        case CMD_CALENDAR_WEEK_SHOW:         
        case CMD_CALENDAR_DAY_SHOW:         
        case CMD_CALENDAR_EVENTS_SHOW:  
             {       
             WRITE ("<A HREF=\"%s/%s/help/calendar_show/%s/%s/%s/%d/%d/%d/\">", PATH_CGI, SERVICE_CALENDAR, lang, user, connid, validator, pageid, cmdactual); break; 
             }
        }
      Image (skin->getI(L_HELP), L->get(ALT_HELP), skin->getISize());  
      if (skin->getDisplayButtonLabels()) {WRITE (" %s\n", L->get(ALT_HELP));}
      WRITE ("</A>");
      EndTD();  
      
      //SPACE 
      EmptyCellx2();     
      //BUTTON LOGOUT   
      BeginTD (1, skin->getSkinAtribProp("FONT_MAIN"), skin->getSkinAtribPropI("FONT_BOTONERA_SIZE"), "center");
      if (uo->getConfirmLogout() == true)    
        {
        WRITE ("<A HREF=\"%s/%s/conf_act/logout/%s/%s/%s/%d/%d/%d/\">", PATH_CGI, SERVICE_MAIN, lang, user, connid, validator, pageid, cmdactual);
        }
      else
        {  
        WRITE ("<A HREF=\"%s/%s/logout/noop/%s/%s/%s/%d/%d/%d/\">", PATH_CGI, SERVICE_MAIN, lang, user, connid, validator, pageid, cmdactual);
        }
      Image (skin->getI(L_LOGOUT), L->get(ALT_LOGOUT), skin->getISize());
      if (skin->getDisplayButtonLabels()) {WRITE (" %s\n", L->get(ALT_LOGOUT));}
      WRITE ("</A>");
      EndTD();
      BeginTD (100, skin->getSkinAtribProp("FONT_MAIN"), skin->getSkinAtribPropI("FONT_BOTONERA_SIZE"), "center"); WRITE (HTML_HSP); EndTD(); 
    EndTR();
  EndTable ();  
  PrintStatusLine_Calendar (user, uo, true, cclient->getMailboxName());
  }

//retrieve the url for the Service icon
const char *GetService_Calendar_ICO_URL (void)
  {
  return skin->getI(L_CALENDAR);
  }

//Retrieve the ALT tag for the Service icon
const char *GetService_Calendar_ICO_ALT (void)
  {
  return L->get(L_CALENDAR);
  }

//Retrieve the Service name
const char *GetService_Calendar_NAME (void)
  {
  return L->get(L_CALENDAR);
  }

//Retrieve the Service Description
const char *GetService_Calendar_DESCRIPTION (void)
  {
  return L->get(L_CALENDAR_DESCRIPTION);
  }

//Entry point to service init
bool DoService_Calendar_BEGIN (TProgData *pd)
  {
  TBuffer file2show;
  if (CheckServiceDisabled (TranslateServiceR(pd->service), file2show) == true) 
    {pd->html->dumpFile (file2show, "TEXT/HTML"); return false;}        
  
  if (Service_Calendar_Initialized == true) {return true;}
  Service_Calendar_Initialized = false;
  LOG ("Initializating Service Calendar for user=%s", pd->username);      

  BeginWeekOnSunday = false;
  workingYear  = CurrentYear ();
  workingMonth = CurrentMonth ();
  workingDay   = CurrentDay ();
    
  Service_Calendar_Initialized = true;    
  return true;
  }

//Entry point to service end
bool DoService_Calendar_END (TProgData *pd)
  {
  if (Service_Calendar_Initialized == false) {return true;}
  
  Service_Calendar_Initialized = false;
    
  return true;
  }

//Entry point to execute a service command
bool DoService_Calendar_CMD (TProgData *pd)
  {
  HTMLPages *html;
  int cmd;

  html = (HTMLPages *)pd->html;

  TBuffer file2show;
  if (CheckServiceDisabled (TranslateServiceR(pd->service), file2show) == true) 
    {pd->html->dumpFile (file2show, "TEXT/HTML"); return false;}        

  cmd = pd->cmd;
                  
  switch (pd->cmd)
    {
    case (CMD_CALENDAR_YEAR_SHOW):   {pd->uo->InitStatusLine (); html->PrintCalendarYearShow (pd); break;}       
    case (CMD_CALENDAR_MONTH_SHOW):  {pd->uo->InitStatusLine (); html->PrintCalendarMonthShow (pd); break;}      
    case (CMD_CALENDAR_WEEK_SHOW):   {pd->uo->InitStatusLine (); html->PrintCalendarWeekShow (pd); break;}       
    case (CMD_CALENDAR_DAY_SHOW):    {pd->uo->InitStatusLine (); html->PrintCalendarDayShow (pd); break;}      
    case (CMD_CALENDAR_EVENTS_SHOW): {pd->uo->InitStatusLine (); html->PrintCalendarEventsShow (pd); break;}      
    default: 
      {    
      //pd->html->dumpFile (pd->envfile, "TEXT/PLAIN");
      LOG ("ERROR: Service_Calendar: Here we can not go!! cmd=%s, subcmd=%s", pd->stcmd, pd->stsubcmd);
      pd->html->PrintInvalidCommand (pd->stlang, pd->username, pd->connid, pd->uo);
      break;
      }         
    }
  return false;  
  }  

void HTMLPages::PrintCalendarMonthShow (TProgData *pd)    
  {
  }
  
void HTMLPages::PrintCalendarWeekShow (TProgData *pd)
  {
  }
  
void HTMLPages::PrintCalendarDayShow (TProgData *pd)    
  {
  }
  
void HTMLPages::PrintCalendarEventsShow (TProgData *pd)        
  {
  }

void HTMLPages::PrintCalendarYearShow (TProgData *pd)
  {
  long jul;
  int dow, begday;
  
  Head ("text/html", "", "");
  HTMLBegin ();
  Title (L->get(TIT_CALENDAR_DISPLAYPAGE), skin->getSkinAtribProp("COLOR_BGBODY"), skin->getSkinAtribProp("COLOR_BGTEXTO"),
         skin->getSkinAtribProp("IMG_BG"), pd->uo->get_use_javascript(), 0, NULL);  
  
  BotoneraComun_Calendar (CMD_CALENDAR_WEEK_SHOW, pd->stlang, pd->username, pd->connid, pd->uo);  

  WRITE ("<CENTER>%s %d</CENTER>\n", L->get(L_CALENDAR), CurrentYear());

  BeginFormPost ("PrintCalendarChangeShow", PATH_CGI);
  FormHidden ("service", SERVICE_CALENDAR);
  FormHidden ("lang", pd->stlang);
  FormHidden ("user", pd->username);        
  FormHidden ("connid", pd->connid);
  FormHidden ("validator", pd->uo->getValidator());
  FormHidden ("pageid", pd->uo->getPageId());
  FormHidden ("cmd", "calendar_do");      
  FormHidden ("subcmd", "noop");        
  FormHidden ("lastcmd", CMD_CALENDAR_WEEK_SHOW);    
  BR();

  if (BeginWeekOnSunday == false) begday = 1; else begday = 0;
  WRITE ("<SMALL>\n");
  WRITE ("<TABLE WIDTH=100%%>\n");
  for (int i = 0; i < NUMBER_MONTHS; ++i)
    {
    if ((i == 0) || (i == 4) || (i == 8)) WRITE ("<TR>\n");
    WRITE ("<TD>\n");    
    WRITE ("<CENTER><B>%s</B><CENTER></BR>\n", getLongMonth(i)); 
    WRITE ("<TABLE>\n");  
    WRITE ("<TR>"); for (int j = 0; j < NUMBER_DAYSFORWEEK; ++j) {WRITE ("<TD><B>%s</B></TD>", getShortDay2(j + begday));} WRITE ("</TR>\n");
    
    WRITE ("<TR>\n");
    jul = GregorianToJulian (0, i, workingYear);
    dow = DayOfWeek (jul);
    WRITE ("--%d--", dow);
    /*
    for (int j = 0; j < DaysOfMonth(i, workingYear) + dow; ++j) 
      {
      if (j < dow) {WRITE("<TD&nbsp;</TD>\n");} else
        {
        if (IsMultiplo(j + begday, 7))
          {
          WRITE ("<TD align=right>%d</TD></TR><TR>", j - dow + 1);
          }
        else
          {   
          WRITE ("<TD align=right>%d</TD>", j - dow + 1); 
          }
        }
      }
    */  
    WRITE ("</TR>\n");
      
    WRITE ("</TABLE>\n");                          
    if ((i == 3) || (i == 7) || (i == 11)) WRITE ("</TR>\n");
    }
  EndTable();
  WRITE ("</SMALL>\n");
  EndForm ();
  HTMLEnd(skin->getSkinAtribProp("COLOR_BGTABLECOPYRIGHT"));            
  }