home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2016 / linuxmafia.com.tar / linuxmafia.com / pub / palmos / wapuniverse-src-0.3.5.build9.tar.gz / wapuniverse-src-0.3.5.build9.tar / wapuniverse-0.3.5.build9 / formEditConnection.c < prev    next >
C/C++ Source or Header  |  2000-11-12  |  7KB  |  223 lines

  1. // ---------------------------------------------------------------------------
  2. // FormEditConnection.c
  3. // Contains PalmOS specific code, for frmEditConnection form
  4. // 
  5. // Project: WAPUniverse for PalmOS
  6. // Copyright ⌐ 1999-2000 Filip Onkelinx
  7. //
  8. // http://www.wapuniverse.com/
  9. // filip@onkelinx.com
  10. //
  11. // This program is free software; you can redistribute it and/or
  12. // modify it under the terms of the GNU General Public License
  13. // as published by the Free Software Foundation; either version 2
  14. // of the License, or (at your option) any later version.
  15. //
  16. // This program is distributed in the hope that it will be useful,
  17. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. // GNU General Public License for more details.
  20. //
  21. // You should have received a copy of the GNU General Public License
  22. // along with this program; if not, write to the Free Software 
  23. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
  24. //
  25. // 
  26. // $Workfile: formEditConnection.c $  
  27. // $Author: wapuniverse $  
  28. // $Date: 2000/11/11 20:51:09 $     
  29. // $Revision: 1.7 $
  30. // 
  31. // $Header: /cvsroot/wapuniverse/wapuniverse/src/formEditConnection.c,v 1.7 2000/11/11 20:51:09 wapuniverse Exp $
  32. // 
  33. // -------------------------------------------------------------------------------
  34. #include    <PalmOS.h>
  35. #include    <SysEvtMgr.h>
  36. #include     "WAPUniverse.h"
  37. #include    "formConnectionList.h"
  38. #include    "formUrlList.h"
  39. #include    "dbConn.h"
  40. #include     "PalmUtils.h"
  41. #include    "formEditConnection.h"
  42. #include     "../res/WAPUniverse_res.h"
  43. #ifdef __GNUC__
  44. #include "callbacks.h"
  45. #endif
  46.  
  47. static Boolean ButtonConnectionSettingsDone_OH(EventPtr event, GlobalsType *g) SEC_1;
  48. static Boolean ButtonConnectionSettingsDelete_OH(EventPtr event, GlobalsType *g) SEC_1;
  49. static void ConnectionDetailsInit (GlobalsType *g) SEC_1;
  50. static UInt16 ConnectionDetailsApply (GlobalsType *g) SEC_1;
  51.  
  52. static void ConnectionDetailsInit (GlobalsType *g)
  53. {
  54.   UInt16                    attr;
  55.   dbConnPackedConnection*    pconn;
  56.   MemHandle                    rechand;
  57.   Int16                     seekAmount = g->DbConnCurrentRecord;
  58.   UInt16                    index = 0;
  59.  
  60.   // must do seek to skip over secret records
  61.   DmSeekRecordInCategory (g->DbConnDb, &index, seekAmount, dmSeekForward, dmAllCategories);
  62.  
  63.   // Get the secret and category attributes of the current record.
  64.   DmRecordInfo (g->DbConnDb, index, &attr, NULL, NULL);
  65. //  gRecordCategory = attr & dmRecAttrCategoryMask;
  66.  
  67.   rechand = DmQueryRecord (g->DbConnDb, index);
  68.   pconn = MemHandleLock (rechand);
  69.   dbConnUnPackConnection (&(g->CurrentConnection), pconn);
  70.  
  71.   SetFieldFromStr(g->CurrentConnection.name , fldConnectionName);
  72.   SetFieldFromStr(g->CurrentConnection.ipaddress , fldIPAddress);
  73.   
  74.   MemHandleUnlock (rechand);
  75.  
  76. }
  77.  
  78. static UInt16 ConnectionDetailsApply (GlobalsType *g)
  79. {
  80.   UInt16            attr;
  81.   UInt16            updateCode = 0;
  82.   dbConnConnection     tConn;
  83.   MemHandle            currec;
  84.   FormPtr             frm;
  85.   FieldPtr            ipPtr;
  86.   Int16             seekAmount = g->DbConnCurrentRecord;
  87.   UInt16            index = 0;
  88.  
  89.   // must do seek to skip over secret records
  90.   DmSeekRecordInCategory (g->DbConnDb, &index, seekAmount, dmSeekForward, dmAllCategories);
  91.  
  92.   // Get the secret and category attributes of the current record.
  93.   DmRecordInfo (g->DbConnDb, index, &attr, NULL, NULL);
  94.  
  95.   frm = FrmGetFormPtr (frmEditConnection);
  96.   ipPtr = (FieldPtr) (FrmGetObjectPtr (frm, (FrmGetObjectIndex (frm, fldConnectionName))));
  97.   if (FldGetTextPtr (ipPtr) != NULL)
  98.     StrCopy (tConn.name, FldGetTextPtr (ipPtr));
  99.   ipPtr = (FieldPtr) (FrmGetObjectPtr (frm, (FrmGetObjectIndex (frm, fldIPAddress))));
  100.   if (FldGetTextPtr (ipPtr) != NULL)
  101.     StrCopy (tConn.ipaddress, FldGetTextPtr (ipPtr));
  102.   tConn.security = 'N';
  103.   tConn.bearer = 'C';
  104.   tConn.connectionType = 'L';
  105.   currec = DmGetRecord (g->DbConnDb, index);
  106.   dbConnPackConnection (&tConn, currec);
  107.   DmReleaseRecord (g->DbConnDb, index, true);
  108.   dbConnSortRecord (g->DbConnDb, &index);
  109.  
  110.   return updateCode;
  111. }
  112.  
  113.  
  114. /**----------------------------------**/
  115. /** Form Event Handler for FormEditSettings**/
  116. /**----------------------------------**/
  117.  
  118. /****************************************************/
  119. /* 
  120.    Function: Boolean FormEditSettings_EH(EventPtr event);
  121.    Description: Main Form Event Handler for FormEditSettings
  122.  */
  123. /****************************************************/
  124.  
  125.  
  126. /* Form Event Handler */
  127. Boolean ehFormEditConnection(EventPtr event)
  128. {
  129.     Boolean handled = false;
  130.     GlobalsType *g;
  131.     
  132. #ifdef __GNUC__
  133.     CALLBACK_PROLOGUE
  134. #endif
  135.  
  136.     FtrGet(wuAppType, ftrGlobals, (UInt32 *)&g);
  137.     switch(event->eType) {
  138.  
  139.         case ctlSelectEvent:
  140.             if (event->data.ctlSelect.controlID == buttonConnectionSettingsDone) {
  141.                 handled = ButtonConnectionSettingsDone_OH(event,g); }
  142.             if (event->data.ctlSelect.controlID == buttonConnectionSettingsDelete) {
  143.                 handled = ButtonConnectionSettingsDelete_OH(event,g); }
  144.             break;
  145.  
  146.         case ctlRepeatEvent:
  147.             break;
  148.  
  149.         case tblSelectEvent:
  150.             break;
  151.  
  152.         case lstSelectEvent:
  153.         case popSelectEvent:
  154.             break;
  155.  
  156.         case sclEnterEvent:
  157.             break;
  158.  
  159.         case frmOpenEvent:
  160.            ConnectionDetailsInit(g);
  161.            FrmDrawForm(FrmGetActiveForm());
  162.            handled = true;
  163.            break;
  164.     default:
  165.        break;
  166.  
  167.  
  168.            }
  169. #ifdef __GNUC__
  170.     CALLBACK_EPILOGUE
  171. #endif
  172.     return handled;
  173. }
  174.  
  175.  
  176. /* Item Handler Functions Here */
  177.  
  178. /**--------------------------------------**/
  179. /** Form Object Handler Functions for FormEditSettings **/
  180. /**--------------------------------------**/
  181.  
  182. /****************************************************/
  183. /* 
  184.    Function: Int16 ButtonConnectionSettingsDone_OH(EventPtr event);
  185.    Description: Button Object Handler for the FormEditSettings Form
  186.  */
  187. /****************************************************/
  188.  
  189. static Boolean ButtonConnectionSettingsDone_OH(EventPtr event, GlobalsType *g)
  190. {
  191.     ConnectionDetailsApply (g);
  192.     FrmCloseAllForms ();
  193.     g->CurrentView = frmConnectionList;
  194.  
  195.     FrmGotoForm (g->CurrentView);
  196.     return(true);
  197. }
  198.  
  199.  
  200. /****************************************************/
  201. /* 
  202.    Function: Int16 ButtonConnectionSettingsDelete_OH(EventPtr event);
  203.    Description: Button Object Handler for the FormEditSettings Form
  204.  */
  205. /****************************************************/
  206.  
  207. static Boolean ButtonConnectionSettingsDelete_OH(EventPtr event, GlobalsType *g)
  208. {
  209.     // The delete button was pressed.  Delete the current record.
  210.     if ( dbConnDeleteCurrentRecord (g))
  211.     {
  212.        // Delete was completed.  Close the details and the edit forms.
  213.        FrmCloseAllForms ();
  214.  
  215.        // Go to the main form.
  216.        g->CurrentView = frmConnectionList;
  217.        FrmGotoForm (g->CurrentView);
  218.     }
  219.     return(true);
  220. }
  221.  
  222.  
  223.