pjs/profile/Acctidl/nsAccountServices.cpp

167 строки
3.7 KiB
C++
Исходник Обычный вид История

1999-07-23 08:37:23 +04:00
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
1999-07-23 08:37:23 +04:00
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
1999-07-23 08:37:23 +04:00
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
1999-07-23 08:37:23 +04:00
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Pierre Phaneuf <pp@ludusdesign.com>
1999-07-23 08:37:23 +04:00
*/
/*
A sample of XPConnect. This file contains an implementation of
nsIAccountServices.
*/
1999-08-21 05:44:41 +04:00
#include "windows.h"
1999-07-23 08:37:23 +04:00
#include "nscore.h"
#include "nsIAccountServices.h"
#include "nsIMemory.h"
1999-07-23 08:37:23 +04:00
#include "plstr.h"
#include "stdio.h"
#include "nsIAccount.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
static NS_DEFINE_CID(kAccountCID, NS_Account_CID);
class AccountServicesImpl : public nsIAccountServices
{
public:
AccountServicesImpl();
virtual ~AccountServicesImpl();
// nsISupports interface
NS_DECL_ISUPPORTS
// nsIAccount interface
NS_DECL_NSIACCOUNTSERVICES
1999-07-23 08:37:23 +04:00
private:
nsIAccount *mAccount;
};
////////////////////////////////////////////////////////////////////////
nsresult
NS_NewAccountServices(nsIAccountServices** aAccount)
{
NS_PRECONDITION(aAccount != nsnull, "null ptr");
if (! aAccount)
return NS_ERROR_NULL_POINTER;
*aAccount = new AccountServicesImpl();
if (! *aAccount)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aAccount);
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
AccountServicesImpl::AccountServicesImpl()
: mAccount(nsnull)
{
NS_INIT_REFCNT();
nsresult rv = nsServiceManager::GetService(kAccountCID,
NS_GET_IID(nsIAccount),
1999-07-23 08:37:23 +04:00
(nsISupports **)&mAccount);
}
AccountServicesImpl::~AccountServicesImpl()
{
}
NS_IMPL_ISUPPORTS(AccountServicesImpl, NS_GET_IID(nsIAccountServices));
1999-07-23 08:37:23 +04:00
NS_IMETHODIMP
AccountServicesImpl::SetDialerConfig(const char* aPrefix)
{
NS_PRECONDITION(aPrefix != nsnull, "null ptr");
if (! aPrefix)
return NS_ERROR_NULL_POINTER;
printf("Hey : You are here..........%s \n", aPrefix);
mAccount->SetDialerConfig((char *)aPrefix);
return NS_OK;
}
1999-08-21 05:44:41 +04:00
NS_IMETHODIMP
AccountServicesImpl::GetAcctConfig(char** AccountList)
{
nsString localVar;
mAccount->GetAcctConfig(localVar);
*AccountList = PL_strdup(localVar.ToNewCString());
return NS_OK;
}
NS_IMETHODIMP
AccountServicesImpl::GetModemConfig(char** ModemList)
{
nsString localVar;
mAccount->GetModemConfig(localVar);
*ModemList = PL_strdup(localVar.ToNewCString());
return NS_OK;
}
NS_IMETHODIMP
AccountServicesImpl::GetSiteName(char** SiteList)
{
nsString localVar;
mAccount->GetSiteName(localVar);
*SiteList = PL_strdup(localVar.ToNewCString());
return NS_OK;
}
NS_IMETHODIMP
AccountServicesImpl::GetPhone(char** PhoneList)
{
nsString localVar;
mAccount->GetPhone(localVar);
*PhoneList = PL_strdup(localVar.ToNewCString());
return NS_OK;
}
NS_IMETHODIMP
AccountServicesImpl::LoadValues(void)
{
mAccount->LoadValues();
return NS_OK;
}
NS_IMETHODIMP
AccountServicesImpl::CheckForDun(char** dunlist)
{
nsString localVar;
mAccount->CheckForDun(localVar);
*dunlist =PL_strdup(localVar.ToNewCString());
return NS_OK;
}