mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 04:15:43 +00:00
Added the user agent string getter methods to nsINetService, as well as the implementation of them. Note: that they current aren't being initialized.
This commit is contained in:
parent
c8f258ff5f
commit
2f1ae6fbea
@ -20,6 +20,7 @@
|
||||
#define nsINetService_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString2.h"
|
||||
|
||||
class nsIUrl;
|
||||
class nsIProtocolConnection;
|
||||
@ -81,6 +82,59 @@ public:
|
||||
*/
|
||||
NS_IMETHOD HasActiveConnections() = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Get the application name string that will be used as part
|
||||
* of a HTTP request.
|
||||
*
|
||||
* @param aAppCodeName The application name string.
|
||||
* @return Returns NS_OK if successful, or NS_FALSE if an error occurred.
|
||||
*/
|
||||
NS_IMETHOD GetAppCodeName(nsString2& aAppCodeName)=0;
|
||||
|
||||
/**
|
||||
* Get the application version string that will be used as part
|
||||
* of a HTTP request.
|
||||
*
|
||||
* @param aAppVersion The application version string.
|
||||
* @return Returns NS_OK if successful, or NS_FALSE if an error occurred.
|
||||
*/
|
||||
NS_IMETHOD GetAppVersion(nsString2& aAppVersion)=0;
|
||||
|
||||
/**
|
||||
* Get the application name.
|
||||
*
|
||||
* @param aAppName The application name.
|
||||
* @return Returns NS_OK if successful, or NS_FALSE if an error occurred.
|
||||
*/
|
||||
NS_IMETHOD GetAppName(nsString2& aAppName)=0;
|
||||
|
||||
/**
|
||||
* Get the translation of the application. The value for language
|
||||
* is usually a 2-letter code such as "en" and occasionally a
|
||||
* five-character code to indicate a language subtype, such as "zh_CN".
|
||||
*
|
||||
* @param aLanguage The application language.
|
||||
* @return Returns NS_OK if successful, or NS_FALSE if an error occurred.
|
||||
*/
|
||||
NS_IMETHOD GetLanguage(nsString2& aLanguage)=0;
|
||||
|
||||
/**
|
||||
* Get the current platform (machine type).
|
||||
*
|
||||
* @param aPlatform The current platform.
|
||||
* @return Returns NS_OK if successful, or NS_FALSE if an error occurred.
|
||||
*/
|
||||
NS_IMETHOD GetPlatform(nsString2& aPlatform)=0;
|
||||
|
||||
/**
|
||||
* Get the HTTP advertised user agent string.
|
||||
*
|
||||
* @param aUA The current user agent string being sent out in HTTP requests.
|
||||
* @retrun Returns NS_OK if successful, or NS_FALSE if an error occurred.
|
||||
*/
|
||||
NS_IMETHOD GetUserAgent(nsString2& aUA)=0;
|
||||
|
||||
};
|
||||
|
||||
#endif /* nsIINetService_h___ */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
@ -28,6 +28,9 @@
|
||||
#include "nsConnectionGroup.h"
|
||||
#include <ctype.h> // for isalpha
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nspr.h"
|
||||
|
||||
|
||||
|
||||
static NS_DEFINE_CID(kFileTransportService, NS_FILETRANSPORTSERVICE_CID);
|
||||
static NS_DEFINE_CID(kEventQueueService, NS_EVENTQUEUESERVICE_CID);
|
||||
@ -223,6 +226,45 @@ nsNetService::HasActiveConnections()
|
||||
#endif
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNetService::GetAppCodeName(nsString2& aAppCodeName) {
|
||||
aAppCodeName.SetString(XP_AppCodeName);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNetService::GetAppVersion(nsString2& aAppVersion) {
|
||||
aAppVersion.SetString(XP_AppVersion);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNetService::GetAppName(nsString2& aAppName) {
|
||||
aAppName.SetString(XP_AppName);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNetService::GetLanguage(nsString2& aLanguage) {
|
||||
aLanguage.SetString(XP_AppLanguage);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNetService::GetPlatform(nsString2& aPlatform) {
|
||||
aPlatform.SetString(XP_AppPlatform);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNetService::GetUserAgent(nsString2& aUA) {
|
||||
// XXX this should load the http module and ask for the user agent string from it.
|
||||
char buf[64];
|
||||
PR_snprintf(buf, 64, "%.100s/%.90s", XP_AppCodeName.GetBuffer(), XP_AppVersion.GetBuffer());
|
||||
aUA.SetString(buf);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//////////////////////////
|
||||
//// HELPER ROUTINES
|
||||
//////////////////////////
|
||||
|
@ -41,6 +41,13 @@ public:
|
||||
nsIProtocolConnection* *result);
|
||||
NS_IMETHOD HasActiveConnections();
|
||||
|
||||
NS_IMETHOD GetAppCodeName(nsString2& aAppCodeName);
|
||||
NS_IMETHOD GetAppVersion(nsString2& aAppVersion);
|
||||
NS_IMETHOD GetAppName(nsString2& aAppName);
|
||||
NS_IMETHOD GetLanguage(nsString2& aLanguage);
|
||||
NS_IMETHOD GetPlatform(nsString2& aPlatform);
|
||||
NS_IMETHOD GetUserAgent(nsString2& aUA);
|
||||
|
||||
// nsNetService methods:
|
||||
nsNetService();
|
||||
virtual ~nsNetService();
|
||||
@ -48,7 +55,11 @@ public:
|
||||
nsresult Init();
|
||||
|
||||
protected:
|
||||
|
||||
nsString2 XP_AppName;
|
||||
nsString2 XP_AppCodeName;
|
||||
nsString2 XP_AppVersion;
|
||||
nsString2 XP_AppLanguage;
|
||||
nsString2 XP_AppPlatform;
|
||||
};
|
||||
|
||||
#endif // nsNetService_h__
|
||||
|
Loading…
Reference in New Issue
Block a user