VirtualBox

source: vbox/trunk/src/VBox/Main/src-server/HostDnsService.cpp@ 49234

Last change on this file since 49234 was 49228, checked in by vboxsync, 11 years ago

Main/HostDnsService: Lockee & ALock (not used for now).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.8 KB
Line 
1/* $Id: HostDnsService.cpp 49228 2013-10-22 12:24:28Z vboxsync $ */
2/** @file
3 * Base class fo Host DNS & Co services.
4 */
5
6/*
7 * Copyright (C) 2013 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#include <VBox/com/array.h>
19#include <VBox/com/ptr.h>
20#include <VBox/com/string.h>
21
22#include <iprt/cpp/utils.h>
23
24#include "VirtualBoxImpl.h"
25#include <iprt/thread.h>
26#include <iprt/semaphore.h>
27#include <iprt/critsect.h>
28#include "HostDnsService.h"
29
30/* Lockee */
31Lockee::Lockee(){ RTCritSectInit(&mLock);}
32
33
34Lockee::~Lockee(){RTCritSectDelete(&mLock);}
35
36
37const RTCRITSECT* Lockee::lock() const {return &mLock;}
38
39/* ALock */
40ALock::ALock(const Lockee *l):lck(l)
41{
42 RTCritSectEnter(const_cast<PRTCRITSECT>(lck->lock()));
43}
44
45ALock::~ALock()
46{
47 RTCritSectLeave(const_cast<PRTCRITSECT>(lck->lock()));
48}
49
50
51HostDnsService::HostDnsService(){}
52
53HostDnsService::~HostDnsService ()
54{
55 int rc = RTCritSectDelete(&m_hCritSect);
56 AssertRC(rc);
57}
58
59
60HRESULT HostDnsService::init(const VirtualBox *aParent)
61{
62 mParent = aParent;
63
64 int rc = RTCritSectInit(&m_hCritSect);
65 AssertRCReturn(rc, E_FAIL);
66 return S_OK;
67}
68
69HRESULT HostDnsService::start()
70{
71 return S_OK;
72}
73
74void HostDnsService::stop()
75{
76}
77
78HRESULT HostDnsService::update()
79{
80 unconst(mParent)->onHostNameResolutionConfigurationChange();
81 return S_OK;
82}
83
84STDMETHODIMP HostDnsService::COMGETTER(NameServers)(ComSafeArrayOut(BSTR, aNameServers))
85{
86 RTCritSectEnter(&m_hCritSect);
87 com::SafeArray<BSTR> nameServers(m_llNameServers.size());
88
89 Utf8StrListIterator it;
90 int i = 0;
91 for (it = m_llNameServers.begin(); it != m_llNameServers.end(); ++it, ++i)
92 (*it).cloneTo(&nameServers[i]);
93
94 nameServers.detachTo(ComSafeArrayOutArg(aNameServers));
95
96 RTCritSectLeave(&m_hCritSect);
97
98 return S_OK;
99}
100
101
102STDMETHODIMP HostDnsService::COMGETTER(DomainName)(BSTR *aDomainName)
103{
104 RTCritSectEnter(&m_hCritSect);
105
106 m_DomainName.cloneTo(aDomainName);
107
108 RTCritSectLeave(&m_hCritSect);
109
110 return S_OK;
111}
112
113
114STDMETHODIMP HostDnsService::COMGETTER(SearchStrings)(ComSafeArrayOut(BSTR, aSearchStrings))
115{
116 RTCritSectEnter(&m_hCritSect);
117
118 com::SafeArray<BSTR> searchString(m_llSearchStrings.size());
119
120 Utf8StrListIterator it;
121 int i = 0;
122 for (it = m_llSearchStrings.begin(); it != m_llSearchStrings.end(); ++it, ++i)
123 (*it).cloneTo(&searchString[i]);
124
125
126 searchString.detachTo(ComSafeArrayOutArg(aSearchStrings));
127
128 RTCritSectLeave(&m_hCritSect);
129
130 return S_OK;
131}
132
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette