Bug 366337 - implement nsIIdleService on Windows (second attempt)

r=emaijala@kolumbus.fi (Ere Maijala)
sr=neil@parkwaycc.co.uk (Neil Rashbrook)
This commit is contained in:
gijskruitbosch%gmail.com 2007-01-25 21:13:32 +00:00
Родитель 325a0517a8
Коммит 6138557ecb
4 изменённых файлов: 117 добавлений и 0 удалений

Просмотреть файл

@ -50,6 +50,7 @@
#include "nsAppShellSingleton.h"
#include "nsIServiceManager.h"
#include "nsSound.h"
#include "nsIdleServiceWin.h"
#include "nsBidiKeyboard.h"
@ -79,6 +80,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsFilePicker)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsIdleServiceWin)
#endif
NS_GENERIC_FACTORY_CONSTRUCTOR(nsToolkit)
@ -128,6 +130,10 @@ static const nsModuleComponentInfo components[] =
NS_BIDIKEYBOARD_CID,
"@mozilla.org/widget/bidikeyboard;1",
nsBidiKeyboardConstructor },
{ "User Idle Service",
NS_IDLE_SERVICE_CID,
"@mozilla.org/widget/idleservice;1",
nsIdleServiceWinConstructor },
#endif
{ "Native Theme Renderer",
NS_THEMERENDERER_CID,

Просмотреть файл

@ -103,6 +103,7 @@ CPPSRCS += \
nsImageClipboard.cpp \
nsBidiKeyboard.cpp \
nsSound.cpp \
nsIdleServiceWin.cpp \
$(NULL)
endif

Просмотреть файл

@ -0,0 +1,56 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim:expandtab:shiftwidth=4:tabstop=4:
*/
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Gijs Kruitbosch <gijskruitbosch@gmail.com>.
* Portions created by the Initial Developer are Copyright (C) 2007
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Gijs Kruitbosch <gijskruitbosch@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIdleServiceWin.h"
#include <windows.h>
NS_IMPL_ISUPPORTS1(nsIdleServiceWin, nsIIdleService)
NS_IMETHODIMP
nsIdleServiceWin::GetIdleTime(PRUint32 *aTimeDiff)
{
LASTINPUTINFO inputInfo;
inputInfo.cbSize = sizeof(inputInfo);
if (!::GetLastInputInfo(&inputInfo))
return NS_ERROR_FAILURE;
*aTimeDiff = GetTickCount() - inputInfo.dwTime;
return NS_OK;
}

Просмотреть файл

@ -0,0 +1,54 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim:expandtab:shiftwidth=4:tabstop=4:
*/
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Gijs Kruitbosch <gijskruitbosch@gmail.com>.
* Portions created by the Initial Developer are Copyright (C) 2007
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Gijs Kruitbosch <gijskruitbosch@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsIdleServiceWin_h__
#define nsIdleServiceWin_h__
#include "nsIdleService.h"
class nsIdleServiceWin : public nsIdleService
{
public:
NS_DECL_ISUPPORTS
NS_IMETHOD GetIdleTime(PRUint32* idleTime);
};
#endif // nsIdleServiceWin_h__