Initial attempt of AROS port of
[cake.git] / test / Zune / loginwindow.c
blob571e24b0a25b1388dae2031ddb6538ac72b954cb
1 /*
2 Copyright © 2002-2006, The AROS Development Team.
3 All rights reserved.
5 $Id$
6 */
8 #include <exec/types.h>
9 #include <stdlib.h>
10 #include <stdio.h>
11 #include <string.h>
13 #include <proto/alib.h>
14 #include <proto/exec.h>
15 #include <proto/dos.h>
16 #include <proto/intuition.h>
17 #include <proto/muimaster.h>
19 #include <dos/dos.h>
20 #include <intuition/gadgetclass.h>
21 #include <intuition/icclass.h>
22 #include <clib/alib_protos.h>
23 #include <zune/loginwindow.h>
25 #include <libraries/mui.h>
27 Object *app;
29 #define ARG_TEMPLATE "LOCAL/S"
30 #define ARG_LOCAL 0
31 #define TOTAL_ARGS 1
33 int main(void)
35 IPTR argarray[TOTAL_ARGS] = { (IPTR)NULL };
36 struct RDArgs *args=NULL;
37 Object *LoginWin=NULL;
38 char *userName=NULL, *userPass=NULL, *loginMeth=NULL, *string=NULL;
39 struct SecurityBase *SecurityBase=NULL;
40 int error = RETURN_ERROR;
42 if (!(SecurityBase = (struct SecurityBase *)OpenLibrary("security.library", 0)))
44 PutStr("Opening of security.library failed\n");
45 error = ERROR_INVALID_RESIDENT_LIBRARY;
46 goto LibError;
49 args = ReadArgs( ARG_TEMPLATE, argarray, NULL);
51 if (argarray[ARG_LOCAL])
53 app = ApplicationObject,
54 SubWindow, LoginWin = LoginWindowObject,
55 End,
56 End;
58 else
60 string = "Test User";
61 app = ApplicationObject,
62 SubWindow, LoginWin = LoginWindowObject,
63 MUIA_LoginWindow_UserName, (IPTR)string,
64 MUIA_LoginWindow_Method, (IPTR)"smb: NAHOMENET Domain",
65 MUIA_LoginWindow_Method, (IPTR)"smb: aros.org Domain",
66 MUIA_LoginWindow_Method, (IPTR)"smb: Dialup Connection...",
67 MUIA_LoginWindow_Cancel_Disabled, TRUE,
68 End,
69 End;
72 if (app)
74 ULONG sigs = 0;
76 DoMethod
78 LoginWin, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, (IPTR) app,
79 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit
82 set(LoginWin,MUIA_Window_Open,TRUE);
84 while (DoMethod(app, MUIM_Application_NewInput, (IPTR) &sigs) != MUIV_Application_ReturnID_Quit)
86 if (sigs)
88 if (sigs == LWA_RV_OK)
89 break;
91 sigs = Wait(sigs | SIGBREAKF_CTRL_C | SIGBREAKF_CTRL_D);
93 if (sigs & SIGBREAKF_CTRL_C)
94 break;
95 if (sigs & SIGBREAKF_CTRL_D)
96 break;
101 if (sigs == LWA_RV_OK)
103 get(LoginWin, MUIA_LoginWindow_UserName, &string);
104 userName = StrDup(string);
106 get(LoginWin, MUIA_LoginWindow_UserPass, &string);
107 userPass = StrDup(string);
109 get(LoginWin, MUIA_LoginWindow_Method, &string);
110 loginMeth = StrDup(string);
112 Printf(" Hello %s, welcome to aros..\n",userName);
113 Printf(" i shouldnt really say this but your password is '%s'\n",userPass);
114 Printf("\n you have logged on using '%s'\n",loginMeth);
116 FreeVec(string);
117 FreeVec(userName);
118 FreeVec(userPass);
119 FreeVec(loginMeth);
121 error = RETURN_OK;
123 else
125 PutStr(" User canceled");
127 MUI_DisposeObject(app);
129 else
131 printf("Failed to intialize Zune GUI\n");
133 if (args) FreeArgs(args);
135 LibError:
137 CloseLibrary((struct Library *)SecurityBase);
139 return error;