~zulcss/ubuntu/lucid/likewise-open/likewise-open-sru

« back to all changes in this revision

Viewing changes to domainjoin/domainjoin-gui/carbon/DomainJoin/CredentialsDialog.cp

  • Committer: Bazaar Package Importer
  • Author(s): Rick Clark
  • Date: 2008-08-27 08:56:20 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20080827085620-5q0f58b9qtog9myq
Tags: 4.1.0.2956-0ubuntu1
* missing-likewise-logo.diff: removed
* fixed copyright notice
* updated Standards-Version to 3.8.0
* removed path from command in prerm
* removed stop in S runlevel

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  CredentialsDialog.cpp
 
3
 *  DomainJoin
 
4
 *
 
5
 *  Created by Sriram Nambakam on 8/13/07.
 
6
 *  Copyright 2007 Centeris Corporation. All rights reserved.
 
7
 *
 
8
 */
 
9
 
 
10
#include "CredentialsDialog.h"
 
11
#include "DomainJoinDefs.h"
 
12
#include "DomainJoinException.h"
 
13
 
 
14
const int CredentialsDialog::USERNAME_ID      = 204;
 
15
const int CredentialsDialog::PASSWORD_ID      = 206;
 
16
const int CredentialsDialog::CANCEL_BUTTON_ID = 207;
 
17
const int CredentialsDialog::OK_BUTTON_ID     = 208;
 
18
const int CredentialsDialog::CANCEL_CMD_ID    = 'not!';
 
19
const int CredentialsDialog::OK_CMD_ID        = 'ok  ';
 
20
 
 
21
CredentialsDialog::CredentialsDialog(int inAppSignature, TWindow& parentWindow)
 
22
: TSheet(inAppSignature, CFSTR("Window"), CFSTR("Credentials"), parentWindow)
 
23
{
 
24
}
 
25
 
 
26
void
 
27
CredentialsDialog::SetUsername(const std::string& userName)
 
28
{
 
29
    OSStatus err = SetTextControlString(USERNAME_ID, userName);
 
30
        if (err != noErr)
 
31
        {
 
32
           std::string errMsg("Failed to set user name in control");
 
33
           throw DomainJoinException(-1, "Domain Join Error", errMsg);
 
34
        }
 
35
}
 
36
 
 
37
std::string
 
38
CredentialsDialog::GetUsername()
 
39
{
 
40
    std::string result;
 
41
    OSStatus err = GetTextControlString(USERNAME_ID, result);
 
42
        if (err != noErr)
 
43
        {
 
44
           std::string errMsg("Failed to get user name from control");
 
45
           throw DomainJoinException(-1, "Domain Join Error", errMsg);
 
46
        }
 
47
        
 
48
        return result;
 
49
}
 
50
 
 
51
std::string
 
52
CredentialsDialog::GetPassword()
 
53
{
 
54
    std::string result;
 
55
    OSStatus err = GetPasswordControlString(PASSWORD_ID, result);
 
56
        if (err != noErr)
 
57
        {
 
58
           std::string errMsg("Failed to get password from control");
 
59
           throw DomainJoinException(-1, "Domain Join Error", errMsg);
 
60
        }
 
61
        
 
62
        return result;
 
63
}
 
64
 
 
65
void
 
66
CredentialsDialog::SetPassword(const std::string& password)
 
67
{
 
68
    OSStatus err = SetPasswordControlString(PASSWORD_ID, password);
 
69
        if (err != noErr)
 
70
        {
 
71
           std::string errMsg("Failed to set password in control");
 
72
           throw DomainJoinException(-1, "Domain Join Error", errMsg);
 
73
        }
 
74
}
 
75
 
 
76
Boolean
 
77
CredentialsDialog::HandleCommand(const HICommandExtended& inCommand)
 
78
{
 
79
    switch( inCommand.commandID )
 
80
        {
 
81
              case OK_CMD_ID:
 
82
                           this->Close();
 
83
                       PostWindowEvent(CREDENTIALS_CMD_OK, GetParentWindowRef());
 
84
                           return true;
 
85
                  case CANCEL_CMD_ID:
 
86
                           this->Close();
 
87
                       PostWindowEvent(CREDENTIALS_CMD_CANCEL, GetParentWindowRef());
 
88
                           return true;
 
89
              default:
 
90
                       return false;
 
91
        }
 
92
}