File: Service_Finger.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 (172 lines) | stat: -rw-r--r-- 4,352 bytes parent folder | download | duplicates (3)
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
/*                               
Service_Finger.cc
*/

#include "Service_Finger.h"
#include "ClientFinger.h"

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

class HTMLPages: public HTMLBasic
  {
  private:
    //
  public:
    void PrintFingerDisplayPage (const char *stlang, const char *user, const char *connid, UserOptions *uo, 
                                 const char *fserver, const char *fuser, StringList *SLRes);
  };

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

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

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

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

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

//Entry point to service end
bool DoService_Finger_END (TProgData *pd)
  {
  return true;
  }

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

  html = (HTMLPages *)pd->html;

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

  cmd = pd->cmd;
  SLFinger = new StringList;
    
  switch (pd->cmd)
    {
    case (CMD_FINGER_DISPLAYPAGE):
      {
      pd->uo->InitStatusLine ();
      html->PrintFingerDisplayPage (pd->stlang, pd->username, pd->connid, pd->uo, "", "", SLFinger);
      break;   
      }
    case (CMD_FINGER_GO):
      {
      bool b;
      TBuffer ErrMsg, fserver, fuser;
      ClientFinger *CliFi;
      
      cgienv_GetSimpleVar (pd->envfile, "fserver", fserver, true);
      cgienv_GetSimpleVar (pd->envfile, "fuser",   fuser, true);
      CliFi = new ClientFinger (fserver, DEFFINGERPORT, fuser);
      b = CliFi->doFinger (ErrMsg, SLFinger);
      delete CliFi;
      if (b == true) 
        {
        html->PrintFingerDisplayPage (pd->stlang, pd->username, pd->connid, pd->uo, fserver, fuser, SLFinger);
        }
      else 
        {
        LOG ("FINGER: Error: server: %s, user: %s", fserver, fuser);
        html->ErrorPage(ErrMsg);
        }
      break;   
      }      
    default: 
      {    
      LOG ("ERROR: Service_Finger: 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;
      }         
    }
  delete SLFinger;  
  return false;  
  }  

void HTMLPages::PrintFingerDisplayPage 
    (const char *lang, const char *user, const char *connid, UserOptions *uo, 
     const char *fserver, const char *fuser, StringList *SLRes)
  {
  Head ("text/html", "", "");
  HTMLBegin ();
  Title (L->get(TIT_FINGER_DISPLAYPAGE), skin->getSkinAtribProp("COLOR_BGBODY"), skin->getSkinAtribProp("COLOR_BGTEXTO"),
         skin->getSkinAtribProp("IMG_BG"), uo->get_use_javascript(), 0, NULL);  
  
  BotoneraTop (CMD_FINGER_DISPLAYPAGE, lang, user, connid, uo);
  BeginCenter();
  BeginFormPost ("PrintFingerDisplayPage", PATH_CGI);
  FormHidden ("service", SERVICE_FINGER);
  FormHidden ("lang", lang);
  FormHidden ("user", user);
  FormHidden ("connid", connid);
  FormHidden ("validator", uo->getValidator());
  FormHidden ("pageid", uo->getPageId());
  FormHidden ("cmd", "go");      
  FormHidden ("lastcmd", CMD_FINGER_DISPLAYPAGE);    

  Label ("Server:"); FormEdit (50, 20, "fserver", fserver); Label ("User:"); FormEdit (50, 20, "fuser", fuser);
  BR ();
  FormTextArea (uo->getHeightWriteArea(), uo->getWidthWriteArea(), "texttosend", SLRes->toPChar(true), false);  
  BR();
  
  FormButton ("theaction", L->get(L_FINGER));
  EndForm ();
  EndCenter();

  HTMLEnd(skin->getSkinAtribProp("COLOR_BGTABLECOPYRIGHT"));            
  }