1 /*
2 Copyright (C) 2016-2021, Dirk Krause
3 SPDX-License-Identifier: BSD-3-Clause
4 */
5 
6 /*
7 	WARNING: This file was generated by the dkct program (see
8 	http://dktools.sourceforge.net/ for details).
9 	Changes you make here will be lost if dkct is run again!
10 	You should modify the original source and run dkct on it.
11 	Original source: WxpqdicFrame.wxc
12 */
13 
14 /**	@file WxpqdicFrame.cpp The WxpqdicFrame module.
15 */
16 
17 
18 #include "dk4conf.h"
19 
20 #ifndef	DK4_SIZEOF_WXCHAR
21 #ifndef	DK4WXCS_H_INCLUDED
22 #include "dk4wxcs.h"
23 #endif
24 #endif
25 
26 #include <wxpqdic/wxpqdic.h>
27 #include <libdk4c/dk4user.h>
28 #include <libdk4c/dk4enc.h>
29 #include <libdk4base/dk4strd.h>
30 #include <libdk4c/dk4rec.h>
31 #include <libdk4base/dk4str8.h>
32 #include <libdk4wx/dk4strx.h>
33 #include <libdk4wx/dk4recwx.h>
34 #include <libdk4ma/dk4maasz.h>
35 #include <libdk4maio8d/dk4mai8ddu.h>
36 #include <libdk4maio8d/dk4mai8dii.h>
37 #include <libdk4maio8d/dk4mao8d.h>
38 #include <libdk4maiowd/dk4maowd.h>
39 #include <libdk4base/dk4numco.h>
40 
41 
42 #include "gui-img/shared/toolbar/exit-program.xpm"
43 #include "gui-img/shared/toolbar/run-conversion.xpm"
44 
45 #include <libdk4wx/dk4verswx.h>
46 
47 #if !defined(__WXMSW__)
48 #include "gui-img/icons/dkicon.xpm"
49 #endif
50 
51 
52 
53 
54 
55 
56 
57 /*	__CHANGE__ 017: Add further events. */
58 /*	__CHANGE__ 008: Remove OnIdle if no idle processing required. */
59 
60 #if	wxCHECK_VERSION(3,0,0)
61 wxBEGIN_EVENT_TABLE(WxpqdicFrame,wxFrame)
62 #else
63 BEGIN_EVENT_TABLE(WxpqdicFrame,wxFrame)
64 #endif
65 	EVT_MENU(WxpqdicFrame_View_Update, WxpqdicFrame::OnRun)
66 	EVT_MENU(WxpqdicFrame_Quit, WxpqdicFrame::OnQuit)
67 	EVT_MENU(WxpqdicFrame_Help_About, WxpqdicFrame::OnAbout)
68 	EVT_MENU(WxpqdicFrame_Help_Contents, WxpqdicFrame::OnHelpContents)
69 	EVT_TIMER(WxpqdicFrame_Timer, WxpqdicFrame::OnTimer)
70 	EVT_IDLE(WxpqdicFrame::OnIdle)
71 #if	wxCHECK_VERSION(3,0,0)
72 wxEND_EVENT_TABLE()
73 #else
74 END_EVENT_TABLE()
75 #endif
76 
77 
78 
79 static const wxChar versionNumber[] = { DKT_VERSION_WX };
80 
81 
82 
83 #if __GNUC__
84 #pragma GCC diagnostic push
85 #pragma GCC diagnostic ignored "-Wmissing-field-initializers"
86 #endif
87 
88 static const wxCmdLineEntryDesc wxpqdic_cmd_line_entries[] = {
89   {
90     wxCMD_LINE_OPTION,
91     wxT_2("h"),
92     wxT_2("host"),
93     wxT_2("Host to connect to."),
94     wxCMD_LINE_VAL_STRING,
95     0
96   },
97   {
98     wxCMD_LINE_OPTION,
99     wxT_2("p"),
100     wxT_2("port"),
101     wxT_2("Port number to connect to."),
102     wxCMD_LINE_VAL_NUMBER,
103     0
104   },
105   {
106     wxCMD_LINE_OPTION,
107     wxT_2("l"),
108     wxT_2("local-port"),
109     wxT_2("Local port number to use."),
110     wxCMD_LINE_VAL_NUMBER,
111     0
112   },
113   {
114     wxCMD_LINE_OPTION,
115     wxT_2("q"),
116     wxT_2("queue"),
117     wxT_2("Queue name to check."),
118     wxCMD_LINE_VAL_STRING,
119     0
120   },
121   {
122     wxCMD_LINE_OPTION,
123     wxT_2("u"),
124     wxT_2("user"),
125     wxT_2("User name to check."),
126     wxCMD_LINE_VAL_STRING,
127     0
128   },
129   {
130     wxCMD_LINE_OPTION,
131     wxT_2("i"),
132     wxT_2("interval"),
133     wxT_2("Time interval for automatic update."),
134     wxCMD_LINE_VAL_NUMBER,
135     0
136   },
137   {
138     wxCMD_LINE_OPTION,
139     wxT_2("a"),
140     wxT_2("ascii"),
141     wxT_2("Remote host uses ASCII encoding, not UTF-8."),
142     wxCMD_LINE_VAL_NONE,
143     0
144   },
145   { wxCMD_LINE_NONE }
146 };
147 
148 #if __GNUC__
149 #pragma GCC diagnostic pop
150 #endif
151 
152 
153 /**	Key names for preferences.
154 */
155 static	const wxChar * const	wxpqdic_pref_key_names[] = {
156 /* 0 */
157 wxT("printqd.host"),
158 
159 /* 1 */
160 wxT("printqd.port"),
161 
162 /* 2 */
163 wxT("printqd.queue"),
164 
165 /* 3 */
166 wxT("printqd.interval"),
167 
168 /* 4 */
169 wxT("printqd.local"),
170 
171 /* 5 */
172 wxT("printqd.encoding"),
173 
174 NULL
175 
176 };
177 
178 
179 
180 /**	Constant 8-bit strings, not localized.
181 */
182 static	const char * const	wxpqdic_kw[] = {
183 /* 0 */
184 "\n",
185 
186 /* 1 */
187 " ",
188 
189 /* 2 */
190 "info",
191 
192 NULL
193 
194 };
195 
196 
WxpqdicFrame(int wxid,Dk4WxApplicationHelper * applicationHelper,Dk4WxHelpController * hc,int argc,wxChar ** argv,wxChar const * const * localizedTexts,wxChar const * const * nlWx,dkChar const * const * nlDk,bool bSocketsInitialized,dk4_er_t * psockerr)197 WxpqdicFrame::WxpqdicFrame(
198   int			  wxid,
199   Dk4WxApplicationHelper *applicationHelper,
200   Dk4WxHelpController	 *hc,
201   int			  argc,
202   wxChar		**argv,
203   wxChar const * const	 *localizedTexts,
204   wxChar const * const	 *nlWx,
205   dkChar const * const	 *nlDk,
206   bool			  bSocketsInitialized,
207   dk4_er_t		 *psockerr
208 ) : Dk4WxFrame(nlWx[0], applicationHelper, hc, wxid),
209     sHostname(wxT("")),
210     sQueuename(wxT("")),
211     sUsername(wxT("")),
212     cBlack(0, 0, 0),
213     cRed(127, 0, 0),
214     cGreen(0, 127, 0),
215     timer(this, WxpqdicFrame_Timer)
216 
217 {
218   /*	__CHANGE__ 012:	Add further local variables.
219   */
220 
221   /*	__CHANGE__ 012: Initialize further local variables.
222   */
223 
224   sTexts = localizedTexts;
225   sNlWx  = nlWx;
226   sNlDk  = nlDk;
227 #if defined(__WXMSW__)
228   wxIcon	wxpqdic_icon(sNlWx[4]);
229 #else
230   wxIcon	wxpqdic_icon(xpm_dkicon);
231 #endif
232 
233   /*	__CHANGE__ 011:	Initialize further class members.
234   */
235   bSockInit		= bSocketsInitialized;
236   DK4_MEMCPY(&sockerr, psockerr, sizeof(dk4_er_t));
237   pHostname		= NULL;
238   pQueuename		= NULL;
239   pUsername		= NULL;
240   pRequest		= NULL;
241   szRequest		= (size_t)0UL;
242   lUpdateInterval	= 30L;
243   lWaitResponse		= 1L;
244   usPortnumber		= 9100;
245   usLocalPort		= 9100;
246   bIsUtf8		= true;
247   bFirstIdle		= true;
248   bFirstResponse	= true;
249   bIsInitialized	= false;
250   copyArgc		= argc;
251   copyArgv		= argv;
252   sock			= INVALID_SOCKET;
253   iState		= WXPQDIC_STATE_OK;
254   tRequestSended	= (dk4_time_t)0UL;
255   szResponse		= sizeof(bResponse);
256   DK4_MEMRES(&(aAddresses[0]), (2*sizeof(dk4_sockaddr_storage_t)));
257 
258   dkctGUILayoutOK = false;
259   dkctGUIContentsPanel = NULL;
260   mainSizer = NULL;
261   mbMain = NULL;
262   tbMain = NULL;
263   menuFile = NULL;
264   menuView = NULL;
265   menuHelp = NULL;
266   miFileExit = NULL;
267   miViewUpdate = NULL;
268   miHelpAbout = NULL;
269   miHelpContents = NULL;
270   verticalSizer = NULL;
271   contentsSizer = NULL;
272   lLimit = NULL;
273   tLimit = NULL;
274   lUsed = NULL;
275   tUsed = NULL;
276   lAccount = NULL;
277   tAccount = NULL;
278   lAllowed = NULL;
279   tAllowed = NULL;
280   lStatus = NULL;
281   bUpdate = NULL;
282   bExit = NULL;
283   dkctGUIContentsPanel = new wxPanel(this);
284   if(!(dkctGUIContentsPanel)) {
285     goto dkctGUILayoutFinished;
286   }
287 #if wxUSE_MENUS
288   mbMain = new wxMenuBar(
289   );
290   if(!(mbMain)) {
291     goto dkctGUILayoutFinished;
292   }
293   menuFile = new wxMenu(
294   );
295   if(!(menuFile)) {
296     goto dkctGUILayoutFinished;
297   }
298   miFileExit = menuFile->Append(
299     WxpqdicFrame_Quit,
300     sTexts[1],
301     sTexts[2]
302   );
303   if(!(miFileExit)) {
304     goto dkctGUILayoutFinished;
305   }
306   mbMain->Append(menuFile, sTexts[0]);
307   menuView = new wxMenu(
308   );
309   if(!(menuView)) {
310     goto dkctGUILayoutFinished;
311   }
312   miViewUpdate = menuView->Append(
313     WxpqdicFrame_View_Update,
314     sTexts[23],
315     sTexts[24]
316   );
317   if(!(miViewUpdate)) {
318     goto dkctGUILayoutFinished;
319   }
320   mbMain->Append(menuView, sTexts[22]);
321   menuHelp = new wxMenu(
322   );
323   if(!(menuHelp)) {
324     goto dkctGUILayoutFinished;
325   }
326   miHelpAbout = menuHelp->Append(
327     WxpqdicFrame_Help_About,
328     sTexts[4],
329     sTexts[5]
330   );
331   if(!(miHelpAbout)) {
332     goto dkctGUILayoutFinished;
333   }
334   miHelpContents = menuHelp->Append(
335     WxpqdicFrame_Help_Contents,
336     sTexts[6],
337     sTexts[7]
338   );
339   if(!(miHelpContents)) {
340     goto dkctGUILayoutFinished;
341   }
342   mbMain->Append(menuHelp, sTexts[3]);
343   SetMenuBar(mbMain);
344 #endif
345 #if wxUSE_TOOLBAR
346   tbMain = new wxToolBar(
347     this,
348     wxID_ANY
349   );
350   if(!(tbMain)) {
351     goto dkctGUILayoutFinished;
352   }
353   bUpdate = tbMain->AddTool(
354     WxpqdicFrame_View_Update,
355     sTexts[25],
356     xpm_run_conversion,
357     wxNullBitmap,
358     wxITEM_NORMAL,
359     sTexts[24]
360   );
361   if(!(bUpdate)) {
362     goto dkctGUILayoutFinished;
363   }
364   bExit = tbMain->AddTool(
365     WxpqdicFrame_Quit,
366     sTexts[26],
367     xpm_exit_program,
368     wxNullBitmap,
369     wxITEM_NORMAL,
370     sTexts[2]
371   );
372   if(!(bExit)) {
373     goto dkctGUILayoutFinished;
374   }
375   tbMain->Realize();
376   SetToolBar(tbMain);
377 #endif
378   mainSizer = new wxBoxSizer(
379     wxHORIZONTAL
380   );
381   if(!(mainSizer)) {
382     goto dkctGUILayoutFinished;
383   }
384   mainSizer->Add(10, 10, 0);
385   verticalSizer = new wxBoxSizer(
386     wxVERTICAL
387   );
388   if(!(verticalSizer)) {
389     goto dkctGUILayoutFinished;
390   }
391   verticalSizer->Add(10, 10, 0);
392   contentsSizer = new wxGridBagSizer(
393     2, 2
394   );
395   if(!(contentsSizer)) {
396     goto dkctGUILayoutFinished;
397   }
398   lLimit = new wxStaticText(
399     dkctGUIContentsPanel,
400     wxID_ANY,
401     sTexts[13]
402   );
403   if(!(lLimit)) {
404     goto dkctGUILayoutFinished;
405   }
406   contentsSizer->Add(
407     lLimit,
408     wxGBPosition(0, 0),
409     wxGBSpan(1, 1),
410     wxALIGN_RIGHT
411   );
412   tLimit = new wxStaticText(
413     dkctGUIContentsPanel,
414     wxID_ANY,
415     sTexts[14]
416   );
417   if(!(tLimit)) {
418     goto dkctGUILayoutFinished;
419   }
420   contentsSizer->Add(
421     tLimit,
422     wxGBPosition(0, 1),
423     wxGBSpan(1, 1)
424   );
425   lUsed = new wxStaticText(
426     dkctGUIContentsPanel,
427     wxID_ANY,
428     sTexts[15]
429   );
430   if(!(lUsed)) {
431     goto dkctGUILayoutFinished;
432   }
433   contentsSizer->Add(
434     lUsed,
435     wxGBPosition(1, 0),
436     wxGBSpan(1, 1),
437     wxALIGN_RIGHT
438   );
439   tUsed = new wxStaticText(
440     dkctGUIContentsPanel,
441     wxID_ANY,
442     sTexts[27]
443   );
444   if(!(tUsed)) {
445     goto dkctGUILayoutFinished;
446   }
447   contentsSizer->Add(
448     tUsed,
449     wxGBPosition(1, 1),
450     wxGBSpan(1, 1)
451   );
452   contentsSizer->Add(5, 5, wxGBPosition(2, 0), wxGBSpan(1, 1));
453   lAccount = new wxStaticText(
454     dkctGUIContentsPanel,
455     wxID_ANY,
456     sTexts[17]
457   );
458   if(!(lAccount)) {
459     goto dkctGUILayoutFinished;
460   }
461   contentsSizer->Add(
462     lAccount,
463     wxGBPosition(3, 0),
464     wxGBSpan(1, 1),
465     wxALIGN_RIGHT
466   );
467   tAccount = new wxStaticText(
468     dkctGUIContentsPanel,
469     wxID_ANY,
470     sTexts[16]
471   );
472   if(!(tAccount)) {
473     goto dkctGUILayoutFinished;
474   }
475   contentsSizer->Add(
476     tAccount,
477     wxGBPosition(3, 1),
478     wxGBSpan(1, 1)
479   );
480   contentsSizer->Add(5, 5, wxGBPosition(4, 0), wxGBSpan(1, 1));
481   lAllowed = new wxStaticText(
482     dkctGUIContentsPanel,
483     wxID_ANY,
484     sTexts[18]
485   );
486   if(!(lAllowed)) {
487     goto dkctGUILayoutFinished;
488   }
489   contentsSizer->Add(
490     lAllowed,
491     wxGBPosition(5, 0),
492     wxGBSpan(1, 1),
493     wxALIGN_RIGHT
494   );
495   tAllowed = new wxStaticText(
496     dkctGUIContentsPanel,
497     wxID_ANY,
498     sTexts[27]
499   );
500   if(!(tAllowed)) {
501     goto dkctGUILayoutFinished;
502   }
503   contentsSizer->Add(
504     tAllowed,
505     wxGBPosition(5, 1),
506     wxGBSpan(1, 1)
507   );
508   contentsSizer->Add(5, 5, wxGBPosition(6, 0), wxGBSpan(1, 1));
509   lStatus = new wxStaticText(
510     dkctGUIContentsPanel,
511     wxID_ANY,
512     sTexts[21]
513   );
514   if(!(lStatus)) {
515     goto dkctGUILayoutFinished;
516   }
517   contentsSizer->Add(
518     lStatus,
519     wxGBPosition(7, 0),
520     wxGBSpan(1, 2)
521   );
522   verticalSizer->Add(
523     contentsSizer
524   );
525   verticalSizer->Add(10, 10, 0);
526   mainSizer->Add(
527     verticalSizer,
528     1,
529     wxGROW
530   );
531   mainSizer->Add(10, 10, 0);
532   dkctGUIContentsPanel->SetSizer(mainSizer);
533   SetIcon(wxpqdic_icon);
534   dkctGUILayoutOK = true;
535   dkctGUILayoutFinished:
536 #if wxUSE_STATUSBAR
537   if(dkctGUILayoutOK) {
538     CreateStatusBar(1);
539     SetStatusText(sTexts[8]);
540   }
541 #endif
542   if(dkctGUILayoutOK) {
543     mainSizer->Fit(this);
544     mainSizer->SetSizeHints(this);
545   }
546   if(dkctGUILayoutOK) {
547     SetTitle(nlWx[0]);
548   }
549 
550 
551   /*	__CHANGE__ 012:	Release resources allocated by local variables.
552   */
553 }
554 
555 
556 
557 
~WxpqdicFrame()558 WxpqdicFrame::~WxpqdicFrame()
559 {
560 
561   /*	__CHANGE__ 011:	Release resources allocated by further class members.
562   */
563 }
564 
565 
566 
567 bool
CanClose(bool WXUNUSED (isLast))568 WxpqdicFrame::CanClose(bool WXUNUSED(isLast))
569 {
570   bool		back	= true;
571 
572   return back;
573 }
574 
575 
576 void
OnQuit(wxCommandEvent & WXUNUSED (event))577 WxpqdicFrame::OnQuit(wxCommandEvent & WXUNUSED(event))
578 {
579   {
580     wxCriticalSectionLocker	lockCsProtect(csProtect);
581     if (bIsInitialized) {
582       timer.Stop();
583       bIsInitialized = false;
584     }
585   }
586   if (INVALID_SOCKET != sock) {
587     dk4socket_close(sock, NULL);
588     sock = INVALID_SOCKET;
589   }
590   dk4mem_release(pUsername);
591   dk4mem_release(pQueuename);
592   dk4mem_release(pHostname);
593   dk4mem_release(pRequest);
594   Show(false);
595   /*	!!!!! TODO: Release resources */
596   Close();
597 }
598 
599 
600 
601 void
OnAbout(wxCommandEvent & WXUNUSED (event))602 WxpqdicFrame::OnAbout(wxCommandEvent & WXUNUSED(event))
603 {
604   wxString	text(wxT(""));
605   wxString	title(wxT(""));
606 
607   /* Construct message text. */
608   text.Append(sNlWx[0]);
609   text.Append(sNlWx[7]);
610 #if 0
611   text.Append(sNlWx[1]);
612 #endif
613   text.Append(versionNumber);
614   text.Append(sNlWx[8]);
615   text.Append(sTexts[9]);
616   text.Append(sNlWx[2]);
617   text.Append(sNlWx[8]);
618   text.Append(sNlWx[8]);
619   text.Append(sTexts[11]);
620   text.Append(sNlWx[8]);
621   text.Append(sNlWx[9]);
622   text.Append(sNlWx[8]);
623   text.Append(sNlWx[8]);
624   text.Append(sTexts[12]);
625   text.Append(sNlWx[8]);
626   text.Append(sNlWx[10]);
627   text.Append(sNlWx[8]);
628   text.Append(sNlWx[11]);
629   text.Append(sNlWx[8]);
630   text.Append(sNlWx[12]);
631   text.Append(sNlWx[8]);
632   text.Append(sNlWx[13]);
633   text.Append(sNlWx[8]);
634   text.Append(sNlWx[14]);
635   text.Append(sNlWx[8]);
636   text.Append(sNlWx[15]);
637   text.Append(sNlWx[8]);
638 
639   /* Construct dialog box title. */
640   title.Append(sTexts[10]);
641   title.Append(sNlWx[0]);
642 
643   /* Show dialog box. */
644   wxMessageBox(text, title);
645 
646 }
647 
648 
649 
650 void
OnHelpContents(wxCommandEvent & WXUNUSED (event))651 WxpqdicFrame::OnHelpContents(wxCommandEvent & WXUNUSED(event))
652 {
653   DisplayContents();
654 }
655 
656 /*	__CHANGE__ 017:	Event handlers for further events.
657 */
658 
659 /*	__CHANGE__ 014:	Implementation of further methods.
660 */
661 
662 
663 bool
ConfigureAndCheckNeedToClose(int * perrc)664 WxpqdicFrame::ConfigureAndCheckNeedToClose(int *perrc)
665 {
666   wxString		 dummy(wxT(""));
667   dkChar		 buf[1024];
668   char			 c8b[1024];
669   dk4_er_t		 er;
670   wxChar		*pv[] = { NULL, NULL, NULL, NULL, NULL, NULL };
671   wxCStrData		 hnstrdata = dummy.c_str();
672   wxCStrData		 qnstrdata = dummy.c_str();
673   wxCStrData		 unstrdata = dummy.c_str();
674   const wxChar		*cptr;
675   const size_t		 szbuf			= DK4_SIZEOF(buf,dkChar);
676   const size_t		 szc8b			= sizeof(c8b);
677   long		 	 l			= 0L;
678   int		 	 res			= 0;
679   bool			 back			= true;
680 
681   /*	Retrieve some fallback values from preferences.
682   */
683   pAppHelp->GetMultiple(wxpqdic_pref_key_names, pv, 6);
684 
685 
686 
687 
688 
689 
690 
691   /*	Check command line arguments
692   */
693   {
694     wxLogNull log;
695     wxCmdLineParser 	 parser(wxpqdic_cmd_line_entries, copyArgc, copyArgv);
696     res = parser.Parse(false);
697     /*
698 	Check overall parsing of arguments
699     */
700     if (0 != res) {
701       /* ERROR: Failed to parse command line arguments */
702       *perrc = WXPQDIC_FRAME_ERROR_PARSE;
703       goto finished;
704     }
705     /*
706 	Option -a means the remote host wants ASCII data.
707     */
708     if (parser.Found(wxT_2("a"))) {
709       bIsUtf8 = false;
710     } else {
711       if (NULL != pv[5]) {
712         if (0 != dk4strx_casecmp(pv[5], sNlWx[16])) {
713 	  if (0 != dk4strx_casecmp(pv[5], sNlWx[17])) {
714 	    bIsUtf8 = false;
715 	  }
716 	}
717       }
718     }
719     /*
720 	Try to obtain host name from arguments or from preferences.
721     */
722     dk4error_init(&er);
723     cptr = NULL;
724     if (parser.Found(wxT_2("h"), &sHostname)) {
725       hnstrdata = sHostname.c_str();
726       cptr = (wxChar const *)hnstrdata;
727     }
728     else {
729       cptr = pv[0];
730     }
731     if (NULL != cptr) {
732       if (pAppHelp->StringToDk(buf, szbuf, cptr, &er)) {
733         pHostname = dk4str_dup(buf, NULL);
734 	if (NULL == pHostname) {
735 	  /* ERROR: Memory */
736 	  *perrc = WXPQDIC_FRAME_ERROR_MEMORY;
737 	  goto finished;
738 	}
739       } else {
740         /* ERROR: Failed to convert string */
741 	*perrc = WXPQDIC_FRAME_ERROR_STRCONV_HOSTNAME;
742 	goto finished;
743       }
744     }
745     if (NULL == pHostname) {
746       /* ERROR: Missing host name */
747       *perrc = WXPQDIC_FRAME_ERROR_HOSTNAME;
748       goto finished;
749     }
750     /*
751 	Queue name is required.
752     */
753     cptr = NULL;
754     if (parser.Found(wxT_2("q"), &sQueuename)) {
755       qnstrdata = sQueuename.c_str();
756       cptr = (wxChar const *)qnstrdata;
757     }
758     else {
759       cptr = pv[2];
760     }
761     if (NULL != cptr) {
762       res = dk4recwx_wxchar_to_char(
763         c8b, szc8b, ((bIsUtf8) ? (DK4_ENCODING_UTF8) : (DK4_ENCODING_PLAIN)),
764 	cptr, pAppHelp->GetWxEncoding(), NULL
765       );
766       if (0 != res) {
767         pQueuename = dk4str8_dup(c8b, NULL);
768 	if (NULL == pQueuename) {
769 	  /* ERROR: Memory */
770 	  *perrc = WXPQDIC_FRAME_ERROR_MEMORY;
771 	  goto finished;
772 	}
773       } else {
774         /* ERROR: String conversion failed */
775 	*perrc = WXPQDIC_FRAME_ERROR_STRCONV_QUEUENAME;
776 	goto finished;
777       }
778     }
779     else {
780       /* ERROR: Missing queue name */
781       *perrc = WXPQDIC_FRAME_ERROR_QUEUENAME;
782       goto finished;
783     }
784     if (NULL == pQueuename) {
785       /* ERROR: Missing queue name */
786       *perrc = WXPQDIC_FRAME_ERROR_QUEUENAME;
787       goto finished;
788     }
789     /*
790 	Port number is optional.
791     */
792     {
793       bool	portnoFound	= false;
794       l = 0L;
795       if (parser.Found(wxT_2("p"), &l)) {
796         portnoFound = true;
797       }
798       else {
799         if (NULL != pv[1]) {
800 	  wxString s(pv[1]);
801 	  if (s.ToLong(&l, 0)) {
802 	    portnoFound = true;
803 	  }
804 	}
805       }
806       if (portnoFound) {
807 	if ((long)(USHRT_MAX) < l) {
808 	  /* ERROR: Port number out of range */
809 	  *perrc = WXPQDIC_FRAME_ERROR_PORT_OOR;
810 	  goto finished;
811 	}
812 	if (0L == l) {
813 	  /* ERROR: Illegal port number 0 */
814 	  *perrc = WXPQDIC_FRAME_ERROR_PORT_ZERO;
815 	  goto finished;
816 	}
817 	usPortnumber = (unsigned short)l;
818       }
819     }
820     /*
821 	Local port number is optional.
822     */
823     {
824       bool	portnoFound	= false;
825       l = 0L;
826       if (parser.Found(wxT_2("l"), &l)) {
827         portnoFound = true;
828       }
829       else {
830         if (NULL != pv[4]) {
831 	  wxString s(pv[4]);
832 	  if (s.ToLong(&l, 0)) {
833 	    portnoFound = true;
834 	  }
835 	}
836       }
837       if (portnoFound) {
838 	if ((long)(USHRT_MAX) < l) {
839 	  /* ERROR: Port number out of range */
840 	  *perrc = WXPQDIC_FRAME_ERROR_LOCALPORT_OOR;
841 	  goto finished;
842 	}
843 	if (0L == l) {
844 	  /* ERROR: Illegal port number 0 */
845 	  *perrc = WXPQDIC_FRAME_ERROR_LOCALPORT_ZERO;
846 	  goto finished;
847 	}
848 	usLocalPort = (unsigned short)l;
849       }
850     }
851     /*
852 	User name is optional, use current user by default.
853     */
854     if (parser.Found(wxT_2("u"), &sUsername)) {
855       unstrdata = sUsername.c_str();
856       res = dk4recwx_wxchar_to_char(
857         c8b, szc8b, ((bIsUtf8) ? (DK4_ENCODING_UTF8) : (DK4_ENCODING_PLAIN)),
858 	(wxChar const *)unstrdata, pAppHelp->GetWxEncoding(), NULL
859       );
860       if (0 != res) {
861         pUsername = dk4str8_dup(c8b, NULL);
862 	if (NULL == pUsername) {
863 	  /* ERROR: Memory */
864 	  *perrc = WXPQDIC_FRAME_ERROR_MEMORY;
865 	  goto finished;
866 	}
867       }
868       else {
869         /* ERROR: Failed to convert user name */
870 	*perrc = WXPQDIC_FRAME_ERROR_STRCONV_USERNAME;
871 	goto finished;
872       }
873     }
874     else {
875       res = dk4user_get_logname(buf, szbuf, 0, NULL);
876       if (0 != res) {
877         res = dk4recode_dk_to_any(
878 	  c8b, szc8b, ((bIsUtf8) ? (DK4_ENCODING_UTF8) : (DK4_ENCODING_PLAIN)),
879 	  buf, pAppHelp->GetDkEncoding(), NULL
880 	);
881 	if (0 != res) {
882 	  pUsername = dk4str8_dup(c8b, NULL);
883 	  if (NULL == pUsername) {
884 	    /* ERROR: Memory */
885 	    *perrc = WXPQDIC_FRAME_ERROR_MEMORY;
886 	    goto finished;
887 	  }
888 	}
889 	else {
890 	  /* ERROR: Failed to convert user name */
891 	  *perrc = WXPQDIC_FRAME_ERROR_STRCONV_USERNAME;
892 	  goto finished;
893 	}
894       } else {
895         /* ERROR: User name not found! */
896 	*perrc = WXPQDIC_FRAME_ERROR_USERNAME;
897 	goto finished;
898       }
899     }
900     if (NULL == pUsername) {
901       /* ERROR: No user name */
902       *perrc = WXPQDIC_FRAME_ERROR_USERNAME;
903       goto finished;
904     }
905     /*
906 	Interval length is optional.
907     */
908     {
909       bool	intervalFound	= false;
910       l = 0L;
911       if (parser.Found(wxT_2("p"), &l)) {
912         intervalFound = true;
913       }
914       else {
915         if (NULL != pv[3]) {
916 	  wxString s(pv[3]);
917 	  if (s.ToLong(&l, 0)) {
918 	    intervalFound = true;
919 	  }
920 	}
921       }
922       if (intervalFound) {
923         if (5L <= l) {
924 	  lUpdateInterval = l;
925 	} else {
926 	  lUpdateInterval = 5L;
927 	}
928       }
929     }
930     /*
931 	Now build request
932     */
933     dk4error_init(&er);
934     szRequest = strlen(wxpqdic_kw[2]);
935     szRequest = dk4ma_size_t_add(szRequest, dk4str8_len(pQueuename), &er);
936     szRequest = dk4ma_size_t_add(szRequest, dk4str8_len(pUsername), &er);
937     szRequest = dk4ma_size_t_add(szRequest, dk4str8_len(wxpqdic_kw[2]), &er);
938     szRequest = dk4ma_size_t_add(szRequest, 4, &er);
939     if (DK4_E_NONE == er.ec) {
940       pRequest = dk4mem_new(char,szRequest,NULL);
941       if (NULL != pRequest) {
942         if (0 == dk4str8_cpy_s(pRequest, szRequest, wxpqdic_kw[2], NULL)) {
943 	  /* ERROR: BUG */
944 	  *perrc = WXPQDIC_FRAME_ERROR_BUG;
945 	  goto finished;
946 	}
947 	if (0 == dk4str8_cat_s(pRequest, szRequest, wxpqdic_kw[1], NULL)) {
948 	  /* ERROR: BUG */
949 	  *perrc = WXPQDIC_FRAME_ERROR_BUG;
950 	  goto finished;
951 	}
952 	if (0 == dk4str8_cat_s(pRequest, szRequest, pQueuename, NULL)) {
953 	  /* ERROR: BUG */
954 	  *perrc = WXPQDIC_FRAME_ERROR_BUG;
955 	  goto finished;
956 	}
957 	if (0 == dk4str8_cat_s(pRequest, szRequest, wxpqdic_kw[1], NULL)) {
958 	  /* ERROR: BUG */
959 	  *perrc = WXPQDIC_FRAME_ERROR_BUG;
960 	  goto finished;
961 	}
962 	if (0 == dk4str8_cat_s(pRequest, szRequest, pUsername, NULL)) {
963 	  /* ERROR: BUG */
964 	  *perrc = WXPQDIC_FRAME_ERROR_BUG;
965 	  goto finished;
966 	}
967 	if (0 == dk4str8_cat_s(pRequest, szRequest, wxpqdic_kw[0], NULL)) {
968 	  /* ERROR: BUG */
969 	  *perrc = WXPQDIC_FRAME_ERROR_BUG;
970 	  goto finished;
971 	}
972 	szRequest = dk4str8_len(pRequest);
973 
974       } else {
975         /* ERROR: Memory */
976 	*perrc = WXPQDIC_FRAME_ERROR_MEMORY;
977 	goto finished;
978       }
979     } else {
980       /* ERROR: Numeric overflow in size calculation */
981       *perrc = WXPQDIC_FRAME_ERROR_SIZE_CALC_OVERFLOW;
982       goto finished;
983     }
984     /*
985 	Create socket.
986     */
987     sock = dk4socket_udp_client_for_host(
988       aAddresses, pHostname, usPortnumber, usLocalPort, 1, NULL
989     );
990     if (INVALID_SOCKET == sock) {
991       *perrc = WXPQDIC_FRAME_ERROR_SOCKET;
992       goto finished;
993     }
994 
995   }
996 
997 
998 
999   tLimit->SetLabel(sTexts[27]);
1000   tUsed->SetLabel(sTexts[27]);
1001   tAccount->SetLabel(sTexts[27]);
1002 
1003   /*	Finally indicate success.
1004   */
1005   timer.Start(500);
1006   bIsInitialized = true;
1007   back = false;
1008 
1009   /*	Clean up at end and return result.
1010   */
1011   finished:
1012   pAppHelp->ReleaseWxcharStringArray(pv, 6);
1013   if (back) {
1014     if (INVALID_SOCKET != sock) {
1015       dk4socket_close(sock, NULL);
1016       sock = INVALID_SOCKET;
1017     }
1018     dk4mem_release(pUsername);
1019     dk4mem_release(pQueuename);
1020     dk4mem_release(pHostname);
1021     dk4mem_release(pRequest);
1022   }
1023   return back;
1024 }
1025 
1026 
1027 
1028 void
OnIdle(wxIdleEvent & event)1029 WxpqdicFrame::OnIdle(wxIdleEvent & event)
1030 {
1031   int			 errorCode		= WXPQDIC_FRAME_ERROR_NONE;
1032   bool			 mustClose		= false;
1033 
1034   /* __CHANGE__
1035   */
1036   {
1037     wxCriticalSectionLocker	lockCsProtect(csProtect);
1038     if (bFirstIdle) {
1039       bFirstIdle = false;
1040       mustClose = ConfigureAndCheckNeedToClose(&errorCode);
1041     }
1042   }
1043   if (mustClose) {
1044     const wxChar *ti;
1045     const wxChar *tx;
1046     ti = sTexts[58]; tx = sTexts[59];
1047     switch (errorCode) {
1048       case WXPQDIC_FRAME_ERROR_PARSE : {
1049         ti = sTexts[30]; tx = sTexts[31];
1050       } break;
1051       case WXPQDIC_FRAME_ERROR_MEMORY : {
1052         ti = sTexts[32]; tx = sTexts[33];
1053       } break;
1054       case WXPQDIC_FRAME_ERROR_STRCONV_HOSTNAME : {
1055         ti = sTexts[34]; tx = sTexts[35];
1056       } break;
1057       case WXPQDIC_FRAME_ERROR_HOSTNAME : {
1058         ti = sTexts[36]; tx = sTexts[37];
1059       } break;
1060       case WXPQDIC_FRAME_ERROR_STRCONV_QUEUENAME : {
1061         ti = sTexts[38]; tx = sTexts[39];
1062       } break;
1063       case WXPQDIC_FRAME_ERROR_QUEUENAME : {
1064         ti = sTexts[40]; tx = sTexts[41];
1065       } break;
1066       case WXPQDIC_FRAME_ERROR_PORT_OOR : {
1067         ti = sTexts[42]; tx = sTexts[43];
1068       } break;
1069       case WXPQDIC_FRAME_ERROR_PORT_ZERO : {
1070         ti = sTexts[42]; tx = sTexts[44];
1071       } break;
1072       case WXPQDIC_FRAME_ERROR_STRCONV_USERNAME : {
1073         ti = sTexts[45]; tx = sTexts[46];
1074       } break;
1075       case WXPQDIC_FRAME_ERROR_USERNAME : {
1076         ti = sTexts[47]; tx = sTexts[48];
1077       } break;
1078       case WXPQDIC_FRAME_ERROR_LOCALPORT_OOR : {
1079         ti = sTexts[49]; tx = sTexts[50];
1080       } break;
1081       case WXPQDIC_FRAME_ERROR_LOCALPORT_ZERO : {
1082         ti = sTexts[49]; tx = sTexts[51];
1083       } break;
1084       case WXPQDIC_FRAME_ERROR_BUG : {
1085         ti = sTexts[52]; tx = sTexts[53];
1086       } break;
1087       case WXPQDIC_FRAME_ERROR_SIZE_CALC_OVERFLOW : {
1088         ti = sTexts[54]; tx = sTexts[55];
1089       } break;
1090       case WXPQDIC_FRAME_ERROR_SOCKET : {
1091         ti = sTexts[56]; tx = sTexts[57];
1092       } break;
1093     }
1094     wxMessageBox(tx, ti, (wxICON_ERROR | wxOK), this);
1095     Show(false);
1096     Close();
1097   }
1098 
1099   /*	Allow idle handlers from the base class.
1100   */
1101 
1102   event.Skip();
1103 }
1104 
1105 
1106 void
OnTimer(wxTimerEvent & WXUNUSED (event))1107 WxpqdicFrame::OnTimer(wxTimerEvent & WXUNUSED(event))
1108 {
1109   bool	mustUpdate	= false;
1110 
1111   {
1112     wxCriticalSectionLocker	lockCsProtect(csProtect);
1113 
1114     if (bIsInitialized) {
1115       mustUpdate = DataExchangeWithServer();
1116     }
1117 #if TRACE_DEBUG
1118     else {
1119     }
1120 #endif
1121 
1122   }
1123   if (mustUpdate) {
1124     Refresh();
1125     Update();
1126   }
1127 
1128 }
1129 
1130 
1131 
1132 bool
ProcessResponse(bool & found)1133 WxpqdicFrame::ProcessResponse(bool & found)
1134 {
1135   wxChar	 wxb[16*sizeof(dk4_um_t)];
1136   char		*tokens[8];		/* Tokens in the response */
1137   const char	*ep;			/* End part of text */
1138   dk4_um_t	 limit;			/* Print limit */
1139   dk4_um_t	 used;			/* Pages used with in limit */
1140   dk4_um_t	 account;		/* Personal account */
1141   size_t	 sz;			/* Number of tokens used */
1142   size_t	 szwxb;			/* Size of wxb */
1143   int		 founddet;		/* Details found. */
1144   int		 res;			/* Text to number conversion result */
1145   int		 summary;		/* Flag: Can print */
1146   bool		 force;			/* Flag: Force use of values */
1147   bool		 back	= false;
1148 
1149   sz = dk4str8_tokenize(tokens, 8, bResponse, NULL, NULL);
1150   if (4 == sz) {
1151     founddet = 0;
1152     force = bFirstResponse;
1153     switch (iState) {
1154       case WXPQDIC_STATE_TIMEOUT :
1155       case WXPQDIC_STATE_SEND_FAILED :
1156       {
1157         force = true;
1158       } break;
1159     }
1160     if (0 == dk4str8_cmp("-1", tokens[0])) {
1161       limit = DK4_UM_MAX;
1162       founddet |= 1;
1163     } else {
1164       limit = (dk4_um_t)0UL;
1165       ep = NULL;
1166       res = dk4ma_input_c8_dec_dk4_um_t(&limit, tokens[0], &ep, 1, NULL);
1167       if (0 != res) {
1168         founddet |= 1;
1169       }
1170 #if TRACE_DEBUG
1171       else {
1172       }
1173 #endif
1174     }
1175     used = (dk4_um_t)0UL;
1176     ep = NULL;
1177     res = dk4ma_input_c8_dec_dk4_um_t(&used, tokens[1], &ep, 1, NULL);
1178     if (0 != res) {
1179       founddet |= 2;
1180     }
1181 #if TRACE_DEBUG
1182     else {
1183     }
1184 #endif
1185     account = (dk4_um_t)0UL;
1186     ep = NULL;
1187     res = dk4ma_input_c8_dec_dk4_um_t(&account, tokens[2], &ep, 1, NULL);
1188     if (0 != res) {
1189       founddet |= 4;
1190     }
1191 #if TRACE_DEBUG
1192     else {
1193     }
1194 #endif
1195     summary = 0;
1196     ep = NULL;
1197     res = dk4ma_input_c8_dec_int(&summary, tokens[3], &ep, 1, NULL);
1198     if (0 != res) {
1199       founddet |= 8;
1200     }
1201 #if TRACE_DEBUG
1202     else {
1203     }
1204 #endif
1205     if (15 == (15 & founddet)) {
1206       /*	Renew text labels
1207       */
1208 #if DK4_SIZEOF_WXCHAR > 1
1209       szwxb = DK4_SIZEOF(wxb,wxChar);
1210       if ((force) || (limit != uLimit)) {
1211         if (DK4_UM_MAX == limit) {
1212 	  tLimit->SetLabel(sTexts[14]);
1213 	} else {
1214 	  res = dk4ma_write_wc_decimal_unsigned(wxb, szwxb, limit, 0, NULL);
1215 	  if (0 != res) {
1216 	    wxString s(wxb);
1217 	    tLimit->SetLabel(s);
1218 	  }
1219 	}
1220         back = true;
1221       }
1222       if ((force) || (used != uUsed)) {
1223         res = dk4ma_write_wc_decimal_unsigned(wxb, szwxb, used, 0, NULL);
1224 	if (0 != res) {
1225 	  wxString s(wxb);
1226 	  tUsed->SetLabel(s);
1227 	}
1228         back = true;
1229       }
1230       if ((force) || (account != uAccount)) {
1231         res = dk4ma_write_wc_decimal_unsigned(wxb, szwxb, account, 0, NULL);
1232 	if (0 != res) {
1233 	  wxString s(wxb);
1234 	  tAccount->SetLabel(s);
1235 	}
1236         back = true;
1237       }
1238 #else
1239       if ((force) || (limit != uLimit)) {
1240         if (DK4_UM_MAX == limit) {
1241 	  tLimit->SetLabel(sTexts[14]);
1242 	} else {
1243 	  wxString s(tokens[0]);
1244 	  tLimit->SetLabel(s);
1245 	}
1246 	back = true;
1247       }
1248       if ((force) || (used != uUsed)) {
1249         wxString s(tokens[1]);
1250 	tUsed->SetLabel(s);
1251         back = true;
1252       }
1253       if ((force) || (account != uAccount)) {
1254         wxString s(tokens[2]);
1255 	tAccount->SetLabel(s);
1256         back = true;
1257       }
1258 #endif
1259       if ((force) || (summary != iSummary)) {
1260         wxString s(sTexts[(0 != summary) ? 19 : 20]);
1261 	tAllowed->SetLabel(s);
1262 	if (0 != summary) {
1263 	  tAllowed->SetForegroundColour(cGreen);
1264 	} else {
1265 	  tAllowed->SetForegroundColour(cRed);
1266 	}
1267         back = true;
1268       }
1269       if (force) {
1270 	lStatus->SetLabel(sNlWx[5]);
1271         switch (iState) {
1272           case WXPQDIC_STATE_TIMEOUT :
1273           case WXPQDIC_STATE_SEND_FAILED :
1274           {
1275             lStatus->SetForegroundColour(cBlack);
1276           } break;
1277         }
1278       }
1279       /*	Save values for later comparisons
1280       */
1281       uLimit   = limit;
1282       uUsed    = used;
1283       uAccount = account;
1284       iSummary = summary;
1285       bFirstResponse = false;
1286       /*	Change state
1287       */
1288       iState = WXPQDIC_STATE_OK;
1289       found = true;
1290     }
1291 #if TRACE_DEBUG
1292     else {
1293     }
1294 #endif
1295   }
1296 #if TRACE_DEBUG
1297   else {
1298   }
1299 #endif
1300 
1301   return back;
1302 }
1303 
1304 
1305 
1306 bool
RetrieveResponse(void)1307 WxpqdicFrame::RetrieveResponse(void)
1308 {
1309   dk4_sockaddr_storage_t	 remaddr;		/* Source address */
1310   size_t	 		 sz;			/* Buffer size */
1311   size_t	 		 szrema;		/* Address size */
1312   int				 res;			/* Conversion result */
1313   bool				 back	= false;
1314   bool				 found	= false;	/* Flag: Found */
1315 
1316   sz = szResponse;
1317   szrema = sizeof(remaddr);
1318   res = dk4socket_recvfrom(
1319     sock, bResponse, &sz, 0,
1320     (struct sockaddr *)(&remaddr), &szrema,
1321     0L, 10000L, NULL
1322   );
1323   switch (res) {
1324     case DK4_SOCKET_RESULT_SUCCESS :
1325     case DK4_SOCKET_RESULT_IN_PROGRESS :
1326     {
1327       if (0 < sz) {
1328 	bResponse[(szResponse > sz) ? (sz) : (szResponse - 1)] = '\0';
1329 #if TRACE_DEBUG
1330 	dk4str8_delnl(bResponse);
1331 #endif
1332 	if (1 /* ##### TODO: Compare addresses */ ) {
1333 	  back = ProcessResponse(found);
1334 	}
1335 #if TRACE_DEBUG
1336 	else {
1337 	}
1338 #endif
1339       }
1340 #if TRACE_DEBUG
1341       else {
1342       }
1343 #endif
1344     } break;
1345     default : {
1346     } break;
1347   }
1348   if (!(found)) {
1349     if (WXPQDIC_STATE_SENDED == iState) {
1350       iState = WXPQDIC_STATE_TIMEOUT;
1351       tLimit->SetLabel(sTexts[27]);
1352       tUsed->SetLabel(sTexts[27]);
1353       tAccount->SetLabel(sTexts[27]);
1354       tAllowed->SetLabel(sTexts[27]);
1355       tAllowed->SetForegroundColour(cBlack);
1356       lStatus->SetLabel(sTexts[29]);
1357       lStatus->SetForegroundColour(cRed);
1358       back = true;
1359     }
1360   }
1361 
1362   return back;
1363 }
1364 
1365 
1366 
1367 bool
SendRequest(bool force)1368 WxpqdicFrame::SendRequest(bool force)
1369 {
1370   dk4_time_t	 currenttime	= (dk4_time_t)0UL;
1371   size_t	 sz		= 0;
1372   int		 res		= 0;
1373   bool		 mustsend	= false;
1374   bool		 back		= false;
1375 
1376   if ((dk4_time_t)0UL == tRequestSended) {
1377     mustsend = true;
1378   } else {
1379     if (force) {
1380       mustsend = true;
1381     } else {
1382       dk4time_get(&currenttime);
1383       if ((tRequestSended + (dk4_time_t)lUpdateInterval) <= currenttime) {
1384         mustsend = true;
1385       }
1386     }
1387   }
1388   if (mustsend) {
1389     sz = szRequest;
1390     if ((dk4_um_t)0UL == currenttime) {
1391       dk4time_get(&currenttime);
1392     }
1393     res = dk4socket_sendto(
1394       sock, pRequest, &sz, 0,
1395       (struct sockaddr *)(&(aAddresses[0])), sizeof(dk4_sockaddr_storage_t),
1396       0L, 0L, NULL
1397     );
1398     tRequestSended = currenttime;
1399     switch (res) {
1400       case DK4_SOCKET_RESULT_SUCCESS :
1401       case DK4_SOCKET_RESULT_IN_PROGRESS :
1402       {
1403         switch (iState) {
1404 	  case WXPQDIC_STATE_OK : {
1405 	    iState = WXPQDIC_STATE_SENDED;
1406 	  } break;
1407 	}
1408       } break;
1409       default : {
1410         if (WXPQDIC_STATE_SEND_FAILED != iState) {
1411           tLimit->SetLabel(sTexts[27]);
1412 	  tUsed->SetLabel(sTexts[27]);
1413 	  tAccount->SetLabel(sTexts[27]);
1414 	  tAllowed->SetLabel(sTexts[27]);
1415 	  lStatus->SetLabel(sTexts[28]);
1416 	  lStatus->SetForegroundColour(cRed);
1417 	  back = true;
1418 	}
1419         iState = WXPQDIC_STATE_SEND_FAILED;
1420       } break;
1421     }
1422   }
1423 #if TRACE_DEBUG
1424   else {
1425   }
1426 #endif
1427 
1428   return back;
1429 }
1430 
1431 
1432 
1433 void
OnRun(wxCommandEvent & WXUNUSED (event))1434 WxpqdicFrame::OnRun(wxCommandEvent & WXUNUSED(event))
1435 {
1436   bool	mustUpdate	= false;
1437 
1438   {
1439     wxCriticalSectionLocker	lockCsProtect(csProtect);
1440     if (bIsInitialized) {
1441       mustUpdate = SendRequest(true);
1442     }
1443   }
1444   if (mustUpdate) {
1445     Refresh();
1446     Update();
1447   }
1448 
1449 }
1450 
1451 
1452 
1453 bool
DataExchangeWithServer(void)1454 WxpqdicFrame::DataExchangeWithServer(void)
1455 {
1456   bool		 back	=  false;
1457 
1458   if (RetrieveResponse()) {
1459     back = true;
1460   }
1461   if (SendRequest()) {
1462     back = true;
1463   }
1464 
1465   return back;
1466 }
1467 
1468