*** empty log message ***

svn path=/trunk/boinc/; revision=5633
This commit is contained in:
Rom Walton 2005-03-11 22:10:56 +00:00
parent 2e975f231b
commit 88404fb6f7
14 changed files with 1979 additions and 462 deletions

View File

@ -25841,3 +25841,25 @@ David 10 Mar 2005
lib/
boinc_cmd.C
gui_rpc_client.C
Rom 11 Mar 2005
- Add Account Management support into the BOINC Manager.
NOTE: Some problems remain with the current design, such as
pointing out when a username and password combination is
invalid. Currently the only way for somebody to know
something is up is by looking into the messages tab, but
by then the username and password have been recorded in
the acct_mgr_login.xml file because there is no way for
the manager to know something is wrong.
clientgui/
BOINCGUI.pjd
DlgAccountManager.cpp, .h (added)
Events.h
MainDocument.cpp, .h
MainFrame.cpp, .h
lib/
acct_mgr_client.C, .h (added)
gui_rpc_client.C, .h

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,129 @@
// Berkeley Open Infrastructure for Network Computing
// http://boinc.berkeley.edu
// Copyright (C) 2005 University of California
//
// This is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation;
// either version 2.1 of the License, or (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// To view the GNU Lesser General Public License visit
// http://www.gnu.org/copyleft/lesser.html
// or write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#if defined(__GNUG__) && !defined(__APPLE__)
#pragma implementation "DlgAccountManager.h"
#endif
#include "stdwx.h"
#include "BOINCGUIApp.h"
#include "DlgAccountManager.h"
#include "res/boincsm.xpm"
IMPLEMENT_DYNAMIC_CLASS( CDlgAccountManager, wxDialog )
BEGIN_EVENT_TABLE( CDlgAccountManager, wxDialog )
END_EVENT_TABLE()
CDlgAccountManager::CDlgAccountManager()
{
}
CDlgAccountManager::CDlgAccountManager( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
Create(parent, id, caption, pos, size, style);
}
bool CDlgAccountManager::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
////@begin CDlgAccountManager member initialisation
m_AcctManagerUsernameCtrl = NULL;
m_AcctManagerPasswordCtrl = NULL;
////@end CDlgAccountManager member initialisation
////@begin CDlgAccountManager creation
SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS);
wxDialog::Create( parent, id, caption, pos, size, style );
CreateControls();
GetSizer()->Fit(this);
GetSizer()->SetSizeHints(this);
Centre();
////@end CDlgAccountManager creation
return TRUE;
}
void CDlgAccountManager::CreateControls()
{
////@begin CDlgAccountManager content construction
CDlgAccountManager* itemDialog1 = this;
wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
itemDialog1->SetSizer(itemBoxSizer2);
wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
wxFlexGridSizer* itemFlexGridSizer4 = new wxFlexGridSizer(2, 2, 0, 0);
itemBoxSizer3->Add(itemFlexGridSizer4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxStaticText* itemStaticText5 = new wxStaticText;
itemStaticText5->Create( itemDialog1, wxID_STATIC, _("Username:"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT );
itemFlexGridSizer4->Add(itemStaticText5, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 5);
m_AcctManagerUsernameCtrl = new wxTextCtrl;
m_AcctManagerUsernameCtrl->Create( itemDialog1, ID_ACCTMANAGERUSERNAME, _T(""), wxDefaultPosition, wxSize(200, -1), 0 );
itemFlexGridSizer4->Add(m_AcctManagerUsernameCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxStaticText* itemStaticText7 = new wxStaticText;
itemStaticText7->Create( itemDialog1, wxID_STATIC, _("Password:"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT );
itemFlexGridSizer4->Add(itemStaticText7, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 5);
m_AcctManagerPasswordCtrl = new wxTextCtrl;
m_AcctManagerPasswordCtrl->Create( itemDialog1, ID_ACCTMANAGERPASSWORD, _T(""), wxDefaultPosition, wxSize(200, -1), wxTE_PASSWORD );
itemFlexGridSizer4->Add(m_AcctManagerPasswordCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxBoxSizer* itemBoxSizer9 = new wxBoxSizer(wxVERTICAL);
itemBoxSizer3->Add(itemBoxSizer9, 0, wxALIGN_TOP|wxALL, 5);
wxButton* itemButton10 = new wxButton;
itemButton10->Create( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
itemButton10->SetDefault();
itemBoxSizer9->Add(itemButton10, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
wxButton* itemButton11 = new wxButton;
itemButton11->Create( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer9->Add(itemButton11, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
////@end CDlgAccountManager content construction
}
bool CDlgAccountManager::ShowToolTips()
{
return TRUE;
}
wxBitmap CDlgAccountManager::GetBitmapResource( const wxString& name )
{
// Bitmap retrieval
////@begin CDlgAccountManager bitmap retrieval
return wxNullBitmap;
////@end CDlgAccountManager bitmap retrieval
}
wxIcon CDlgAccountManager::GetIconResource( const wxString& name )
{
// Icon retrieval
////@begin CDlgAccountManager icon retrieval
return wxNullIcon;
////@end CDlgAccountManager icon retrieval
}

View File

@ -0,0 +1,108 @@
// Berkeley Open Infrastructure for Network Computing
// http://boinc.berkeley.edu
// Copyright (C) 2005 University of California
//
// This is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation;
// either version 2.1 of the License, or (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// To view the GNU Lesser General Public License visit
// http://www.gnu.org/copyleft/lesser.html
// or write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#ifndef _DLGACCOUNTMANAGER_H_
#define _DLGACCOUNTMANAGER_H_
#if defined(__GNUG__) && !defined(__APPLE__)
#pragma interface "DlgAccountManager.cpp"
#endif
/*!
* Includes
*/
////@begin includes
////@end includes
/*!
* Forward declarations
*/
////@begin forward declarations
////@end forward declarations
/*!
* Control identifiers
*/
////@begin control identifiers
#define ID_DIALOG 10000
#define SYMBOL_CDLGACCOUNTMANAGER_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX
#define SYMBOL_CDLGACCOUNTMANAGER_TITLE _("Account Manager Credentials")
#define SYMBOL_CDLGACCOUNTMANAGER_IDNAME ID_DIALOG
#define SYMBOL_CDLGACCOUNTMANAGER_SIZE wxSize(400, 300)
#define SYMBOL_CDLGACCOUNTMANAGER_POSITION wxDefaultPosition
#define ID_ACCTMANAGERUSERNAME 10001
#define ID_ACCTMANAGERPASSWORD 10002
////@end control identifiers
/*!
* Compatibility
*/
#ifndef wxCLOSE_BOX
#define wxCLOSE_BOX 0x1000
#endif
#ifndef wxFIXED_MINSIZE
#define wxFIXED_MINSIZE 0
#endif
/*!
* CDlgAccountManager class declaration
*/
class CDlgAccountManager: public wxDialog
{
DECLARE_DYNAMIC_CLASS( CDlgAccountManager )
DECLARE_EVENT_TABLE()
public:
/// Constructors
CDlgAccountManager( );
CDlgAccountManager( wxWindow* parent, wxWindowID id = SYMBOL_CDLGACCOUNTMANAGER_IDNAME, const wxString& caption = SYMBOL_CDLGACCOUNTMANAGER_TITLE, const wxPoint& pos = SYMBOL_CDLGACCOUNTMANAGER_POSITION, const wxSize& size = SYMBOL_CDLGACCOUNTMANAGER_SIZE, long style = SYMBOL_CDLGACCOUNTMANAGER_STYLE );
/// Creation
bool Create( wxWindow* parent, wxWindowID id = SYMBOL_CDLGACCOUNTMANAGER_IDNAME, const wxString& caption = SYMBOL_CDLGACCOUNTMANAGER_TITLE, const wxPoint& pos = SYMBOL_CDLGACCOUNTMANAGER_POSITION, const wxSize& size = SYMBOL_CDLGACCOUNTMANAGER_SIZE, long style = SYMBOL_CDLGACCOUNTMANAGER_STYLE );
/// Creates the controls and sizers
void CreateControls();
////@begin CDlgAccountManager event handler declarations
////@end CDlgAccountManager event handler declarations
////@begin CDlgAccountManager member function declarations
/// Retrieves bitmap resources
wxBitmap GetBitmapResource( const wxString& name );
/// Retrieves icon resources
wxIcon GetIconResource( const wxString& name );
////@end CDlgAccountManager member function declarations
/// Should we show tooltips?
static bool ShowToolTips();
////@begin CDlgAccountManager member variables
wxTextCtrl* m_AcctManagerUsernameCtrl;
wxTextCtrl* m_AcctManagerPasswordCtrl;
////@end CDlgAccountManager member variables
};
#endif
// _DLGACCOUNTMANAGER_H_

View File

@ -23,27 +23,28 @@
#define ID_STATUSBAR 6000
#define ID_TOOLSOPTIONS 6001
#define ID_FRAMENOTEBOOK 6002
#define ID_REFRESHSTATETIMER 6003
#define ID_FRAMERENDERTIMER 6004
#define ID_FRAMETASKRENDERTIMER 6005
#define ID_FRAMELISTRENDERTIMER 6006
#define ID_HIDE 6007
#define ID_ACTIVITYRUNALWAYS 6008
#define ID_ACTIVITYRUNBASEDONPREPERENCES 6009
#define ID_ACTIVITYSUSPEND 6010
#define ID_NETWORKRUNALWAYS 6011
#define ID_NETWORKRUNBASEDONPREPERENCES 6012
#define ID_NETWORKSUSPEND 6013
#define ID_RUNBENCHMARKS 6014
#define ID_SELECTCOMPUTER 6015
#define ID_TB_ACTIVITYRUNALWAYS 6016
#define ID_TB_ACTIVITYRUNBASEDONPREPERENCES 6017
#define ID_TB_ACTIVITYSUSPEND 6018
#define ID_TB_NETWORKRUNALWAYS 6019
#define ID_TB_NETWORKRUNBASEDONPREPERENCES 6020
#define ID_TB_NETWORKSUSPEND 6021
#define ID_TOOLSUPDATEACCOUNTS 6001
#define ID_TOOLSOPTIONS 6002
#define ID_FRAMENOTEBOOK 6003
#define ID_REFRESHSTATETIMER 6004
#define ID_FRAMERENDERTIMER 6005
#define ID_FRAMETASKRENDERTIMER 6006
#define ID_FRAMELISTRENDERTIMER 6007
#define ID_HIDE 6008
#define ID_ACTIVITYRUNALWAYS 6009
#define ID_ACTIVITYRUNBASEDONPREPERENCES 6010
#define ID_ACTIVITYSUSPEND 6011
#define ID_NETWORKRUNALWAYS 6012
#define ID_NETWORKRUNBASEDONPREPERENCES 6013
#define ID_NETWORKSUSPEND 6014
#define ID_RUNBENCHMARKS 6015
#define ID_SELECTCOMPUTER 6016
#define ID_TB_ACTIVITYRUNALWAYS 6017
#define ID_TB_ACTIVITYRUNBASEDONPREPERENCES 6018
#define ID_TB_ACTIVITYSUSPEND 6019
#define ID_TB_NETWORKRUNALWAYS 6020
#define ID_TB_NETWORKRUNBASEDONPREPERENCES 6021
#define ID_TB_NETWORKSUSPEND 6022
#define ID_LIST_BASE 7000
#define ID_LIST_PROJECTSVIEW 7000
#define ID_LIST_WORKVIEW 7001

View File

@ -132,6 +132,9 @@ wxInt32 CMainDocument::OnInit()
wxInt32 iRetVal = -1;
wxString strMachine = wxEmptyString;
// attempt to lookup account management information
acct_mgr.init();
if ( !IsConnected() )
iRetVal = Connect( strMachine );
@ -146,6 +149,9 @@ wxInt32 CMainDocument::OnExit()
if ( IsConnected() )
iRetVal = Disconnect();
// attempt to cleanup the account management information
acct_mgr.close();
return iRetVal;
}
@ -2164,4 +2170,53 @@ wxInt32 CMainDocument::SetProxySOCKSPassword( const wxString& strPassword )
}
wxInt32 CMainDocument::GetAccountManagerName( wxString& strName )
{
strName.Clear();
strName = acct_mgr.acct_mgr.name.c_str();
return 0;
}
wxInt32 CMainDocument::InitializeAccountManagerLogin( const wxString& strLogin, const wxString& strPassword )
{
acct_mgr.acct_mgr_login_initialized = true;
acct_mgr.acct_mgr_login.login = strLogin.c_str();
acct_mgr.acct_mgr_login.password = strPassword.c_str();
return 0;
}
wxInt32 CMainDocument::UpdateAccountManagerAccounts()
{
wxInt32 iRetVal = 0;
wxString strEmpty = wxEmptyString;
iRetVal = rpc.acct_mgr_rpc(
acct_mgr.acct_mgr.url.c_str(),
acct_mgr.acct_mgr_login.login.c_str(),
acct_mgr.acct_mgr_login.password.c_str()
);
if (iRetVal)
{
wxLogTrace("CMainDocument::UpdateAccountManagerAccounts - Account Manager RPC Failed '%d'", iRetVal);
Connect( strEmpty );
}
return iRetVal;
}
bool CMainDocument::IsAccountManagerFound()
{
return acct_mgr.acct_mgr_found;
}
bool CMainDocument::IsAccountManagerLoginFound()
{
return acct_mgr.acct_mgr_login_found;
}
const char *BOINC_RCSID_aa03a835ba = "$Id$";

View File

@ -25,6 +25,7 @@
#endif
#include "gui_rpc_client.h"
#include "acct_mgr_client.h"
class CMainDocument : public wxObject
@ -283,6 +284,23 @@ public:
wxInt32 SetProxySOCKSUserName( const wxString& strUserName );
wxInt32 SetProxySOCKSPassword( const wxString& strPassword );
//
// Account Management
//
private:
ACCT_MGR_CLIENT acct_mgr;
public:
wxInt32 GetAccountManagerName( wxString& strName );
wxInt32 InitializeAccountManagerLogin( const wxString& strLogin, const wxString& strPassword );
wxInt32 UpdateAccountManagerAccounts();
bool IsAccountManagerFound();
bool IsAccountManagerLoginFound();
};
#endif

View File

@ -33,6 +33,7 @@
#include "ViewResources.h"
#include "DlgAbout.h"
#include "DlgOptions.h"
#include "DlgAccountManager.h"
#include "res/BOINCGUIApp.xpm"
#include "res/connect.xpm"
@ -147,6 +148,7 @@ BEGIN_EVENT_TABLE (CMainFrame, wxFrame)
EVT_MENU(ID_RUNBENCHMARKS, CMainFrame::OnRunBenchmarks)
EVT_MENU(ID_SELECTCOMPUTER, CMainFrame::OnSelectComputer)
EVT_MENU(wxID_EXIT, CMainFrame::OnExit)
EVT_MENU(ID_TOOLSUPDATEACCOUNTS, CMainFrame::OnToolsUpdateAccounts)
EVT_MENU(ID_TOOLSOPTIONS, CMainFrame::OnToolsOptions)
EVT_MENU(wxID_ABOUT, CMainFrame::OnAbout)
EVT_CLOSE(CMainFrame::OnClose)
@ -254,6 +256,11 @@ bool CMainFrame::CreateMenu()
{
wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::CreateMenu - Function Begin"));
CMainDocument* pDoc = wxGetApp().GetDocument();
wxASSERT(NULL != pDoc);
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
// File menu
wxMenu *menuFile = new wxMenu;
@ -315,6 +322,17 @@ bool CMainFrame::CreateMenu()
// Tools menu
wxMenu *menuTools = new wxMenu;
if ( pDoc->IsAccountManagerFound() )
{
menuTools->Append(
ID_TOOLSUPDATEACCOUNTS,
_("&Update Accounts"),
_("Connect to your account manager website and update all of your accounts")
);
menuFile->AppendSeparator();
}
menuTools->Append(
ID_TOOLSOPTIONS,
_("&Options"),
@ -749,6 +767,42 @@ void CMainFrame::OnExit( wxCommandEvent& WXUNUSED(event) )
}
void CMainFrame::OnToolsUpdateAccounts( wxCommandEvent& WXUNUSED(event) )
{
wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::OnToolsUpdateAccounts - Function Begin"));
CMainDocument* pDoc = wxGetApp().GetDocument();
CDlgAccountManager* pDlg = new CDlgAccountManager(this);
wxInt32 iAnswer = 0;
wxString strLogin = wxEmptyString;
wxString strPassword = wxEmptyString;
wxASSERT(NULL != pDoc);
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
wxASSERT(NULL != pDlg);
if ( !pDoc->IsAccountManagerLoginFound() )
{
iAnswer = pDlg->ShowModal();
if ( wxID_OK == iAnswer )
{
strLogin = pDlg->m_AcctManagerUsernameCtrl->GetValue();
strPassword = pDlg->m_AcctManagerUsernameCtrl->GetValue();
pDoc->InitializeAccountManagerLogin( strLogin, strPassword );
}
}
pDoc->UpdateAccountManagerAccounts();
if (pDlg)
pDlg->Destroy();
wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::OnToolsUpdateAccounts - Function End"));
}
void CMainFrame::OnToolsOptions( wxCommandEvent& WXUNUSED(event) )
{
wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::OnToolsOptions - Function Begin"));

View File

@ -64,6 +64,7 @@ public:
void OnSelectComputer( wxCommandEvent& event );
void OnExit( wxCommandEvent& event );
void OnToolsUpdateAccounts( wxCommandEvent& event );
void OnToolsOptions( wxCommandEvent& event );
void OnAbout( wxCommandEvent& event );

188
lib/acct_mgr_client.C Normal file
View File

@ -0,0 +1,188 @@
// Berkeley Open Infrastructure for Network Computing
// http://boinc.berkeley.edu
// Copyright (C) 2005 University of California
//
// This is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation;
// either version 2.1 of the License, or (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// To view the GNU Lesser General Public License visit
// http://www.gnu.org/copyleft/lesser.html
// or write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#ifdef _WIN32
#include "boinc_win.h"
#include "version.h"
#else
#include "config.h"
#include <sys/types.h>
#include <sys/un.h>
#include <cstdio>
#include <unistd.h>
#include <cstdlib>
#include <cstring>
#endif
#include "diagnostics.h"
#include "parse.h"
#include "error_numbers.h"
#include "miofile.h"
#include "md5_file.h"
#include "acct_mgr_client.h"
using std::string;
using std::vector;
ACCT_MGR::ACCT_MGR() {
clear();
}
ACCT_MGR::~ACCT_MGR() {
clear();
}
int ACCT_MGR::parse(MIOFILE& in) {
char buf[256];
while (in.fgets(buf, 256)) {
if (match_tag(buf, "</acct_mgr>")) return 0;
else if (parse_str(buf, "<name>", name)) continue;
else if (parse_str(buf, "<url>", url)) continue;
}
return ERR_XML_PARSE;
}
void ACCT_MGR::print() {
printf(" name: %s\n", name.c_str());
printf(" url: %s\n", url.c_str());
}
void ACCT_MGR::clear() {
name.clear();
url.clear();
}
ACCT_MGR_LOGIN::ACCT_MGR_LOGIN() {
clear();
}
ACCT_MGR_LOGIN::~ACCT_MGR_LOGIN() {
clear();
}
int ACCT_MGR_LOGIN::parse(MIOFILE& in) {
char buf[256];
while (in.fgets(buf, 256)) {
if (match_tag(buf, "</acct_mgr_login>")) return 0;
else if (parse_str(buf, "<login>", login)) continue;
else if (parse_str(buf, "<password>", password)) continue;
}
return ERR_XML_PARSE;
}
void ACCT_MGR_LOGIN::print() {
printf(" login: %s\n", login.c_str());
printf(" password: %s\n", password.c_str());
}
void ACCT_MGR_LOGIN::clear() {
login.clear();
password.clear();
}
ACCT_MGR_CLIENT::ACCT_MGR_CLIENT()
{
acct_mgr_found = false;
acct_mgr_login_found = false;
acct_mgr_login_initialized = false;
acct_mgr.clear();
acct_mgr_login.clear();
}
ACCT_MGR_CLIENT::~ACCT_MGR_CLIENT()
{
acct_mgr_found = false;
acct_mgr_login_found = false;
acct_mgr_login_initialized = false;
acct_mgr.clear();
acct_mgr_login.clear();
}
int ACCT_MGR_CLIENT::init()
{
char buf[256];
int retval;
MIOFILE mf;
FILE* acct_mgr_file;
FILE* acct_mgr_login_file;
acct_mgr_file = fopen("acct_mgr_url.xml", "r");
if ( NULL != acct_mgr_file ) {
acct_mgr_found = true;
mf.init_file(acct_mgr_file);
while(mf.fgets(buf, sizeof(buf))) {
if (match_tag(buf, "<acct_mgr>")) {
retval = acct_mgr.parse(mf);
if (retval) {
fprintf( stderr, "Can't parse acct_mgr in ACCT_MGR_CLIENT: %d", retval );
}
}
}
}
acct_mgr_login_file = fopen("acct_mgr_login.xml", "r");
if ( (NULL != acct_mgr_login_file) && (0 == retval) ) {
acct_mgr_login_found = true;
mf.init_file(acct_mgr_login_file);
while(mf.fgets(buf, sizeof(buf))) {
if (match_tag(buf, "<acct_mgr_login>")) {
retval = acct_mgr_login.parse(mf);
if (retval) {
fprintf( stderr, "Can't parse acct_mgr_login in ACCT_MGR_CLIENT: %d", retval );
}
}
}
}
fclose(acct_mgr_file);
fclose(acct_mgr_login_file);
return retval;
}
void ACCT_MGR_CLIENT::close()
{
if ( ( false == acct_mgr_login_found ) && ( true == acct_mgr_login_initialized ) ) {
FILE* acct_mgr_login_file;
acct_mgr_login_file = fopen("acct_mgr_login.xml", "w");
if ( NULL != acct_mgr_login_file ) {
fprintf(
acct_mgr_login_file,
"<acct_mgr_login>\n"
" <login>%s</login>\n"
" <password>%s</password>\n"
"</acct_mgr_login>\n",
acct_mgr_login.login.c_str(),
acct_mgr_login.password.c_str()
);
fclose(acct_mgr_login_file);
}
}
}

72
lib/acct_mgr_client.h Normal file
View File

@ -0,0 +1,72 @@
// Berkeley Open Infrastructure for Network Computing
// http://boinc.berkeley.edu
// Copyright (C) 2005 University of California
//
// This is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation;
// either version 2.1 of the License, or (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// To view the GNU Lesser General Public License visit
// http://www.gnu.org/copyleft/lesser.html
// or write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// a C++ interface to BOINC Account Manager Interface
#ifndef _WIN32
#include <stdio.h>
#include <string>
#include <vector>
#endif
#include "miofile.h"
class ACCT_MGR {
public:
std::string name;
std::string url;
ACCT_MGR();
~ACCT_MGR();
int parse(MIOFILE&);
void print();
void clear();
};
class ACCT_MGR_LOGIN {
public:
std::string login;
std::string password;
ACCT_MGR_LOGIN();
~ACCT_MGR_LOGIN();
int parse(MIOFILE&);
void print();
void clear();
};
class ACCT_MGR_CLIENT {
public:
bool acct_mgr_found;
ACCT_MGR acct_mgr;
bool acct_mgr_login_found;
bool acct_mgr_login_initialized;
ACCT_MGR_LOGIN acct_mgr_login;
ACCT_MGR_CLIENT();
~ACCT_MGR_CLIENT();
int init();
void close();
};

View File

@ -1587,14 +1587,14 @@ int RPC_CLIENT::quit() {
return rpc.do_rpc("<quit/>\n");
}
int RPC_CLIENT::acct_mgr_rpc(char* url, char* name, char* passwd) {
int RPC_CLIENT::acct_mgr_rpc(const char* url, const char* name, const char* passwd) {
char buf[4096];
RPC rpc(this);
sprintf(buf,
"<acct_mgr_rpc>\n"
" <url>%s</url>\n"
" <name>%s</name>\n"
" <password>%s</password>\n"
" <passwd>%s</passwd>\n"
"</acct_mgr_rpc>\n",
url, name, passwd
);

View File

@ -407,7 +407,7 @@ public:
int result_op(RESULT&, const char*);
int get_host_info(HOST_INFO&);
int quit();
int acct_mgr_rpc(char* url, char* name, char* passwd);
int acct_mgr_rpc(const char* url, const char* name, const char* passwd);
const char* mode_name(int mode);
};

View File

@ -144,6 +144,15 @@
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath="..\lib\acct_mgr_client.C">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
CompileAs="2"/>
</FileConfiguration>
</File>
<File
RelativePath="..\clientgui\BOINCBaseView.cpp">
</File>
@ -177,6 +186,9 @@
<File
RelativePath="..\clientgui\DlgAbout.cpp">
</File>
<File
RelativePath="..\clientgui\DlgAccountManager.cpp">
</File>
<File
RelativePath="..\clientgui\DlgAttachProject.cpp">
</File>
@ -401,6 +413,9 @@
<File
RelativePath="..\clientgui\_wx_intellisense.h">
</File>
<File
RelativePath="..\lib\acct_mgr_client.h">
</File>
<File
RelativePath="..\lib\boinc_win.h">
</File>
@ -425,6 +440,9 @@
<File
RelativePath="..\clientgui\DlgAbout.h">
</File>
<File
RelativePath="..\clientgui\DlgAccountManager.h">
</File>
<File
RelativePath="..\clientgui\DlgAttachProject.h">
</File>