PageRenderTime 129ms CodeModel.GetById 88ms app.highlight 2ms RepoModel.GetById 38ms app.codeStats 0ms

/thirdparty/liblastfm2/src/ws/win/ComSetup.h

http://github.com/tomahawk-player/tomahawk
C++ Header | 64 lines | 28 code | 6 blank | 30 comment | 2 complexity | 274973bd9e3c2a3f4a3022541c3a738f MD5 | raw file
 1/*
 2   Copyright 2009 Last.fm Ltd. 
 3      - Primarily authored by Max Howell, Jono Cole and Doug Mansell
 4
 5   This file is part of liblastfm.
 6
 7   liblastfm is free software: you can redistribute it and/or modify
 8   it under the terms of the GNU General Public License as published by
 9   the Free Software Foundation, either version 3 of the License, or
10   (at your option) any later version.
11
12   liblastfm is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   GNU General Public License for more details.
16
17   You should have received a copy of the GNU General Public License
18   along with liblastfm.  If not, see <http://www.gnu.org/licenses/>.
19*/
20#ifndef _WIN32_WINNT
21// bring in CoInitializeSecurity from objbase.h
22#define _WIN32_WINNT 0x0400
23#endif
24
25#include <objbase.h>
26#include "winable.h"
27//#include <atlbase.h>
28//#include <atlcom.h>
29
30
31/** @brief WsConnectionMonitor needs Com to work as early as possible so we do this
32  * @author <doug@last.fm> 
33  */
34class ComSetup
35{
36public:
37    ComSetup()
38    {
39        HRESULT hr = CoInitialize(0);
40        m_bComInitialised = SUCCEEDED(hr);
41        //_ASSERT(m_bComInitialised);
42        if (m_bComInitialised) {
43            setupSecurity();
44        }
45    }
46    
47    void setupSecurity()
48    {
49        //CSecurityDescriptor sd;
50        //sd.InitializeFromThreadToken();
51        //HRESULT hr = CoInitializeSecurity(sd, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_PKT, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL); 
52        //_ASSERT(SUCCEEDED(hr));
53    }
54    
55    ~ComSetup()
56    {
57        if (m_bComInitialised) {
58            CoUninitialize();
59        }
60    }
61    
62private:
63    bool m_bComInitialised;
64};