1 | /* $Id: HostDnsService.cpp 48955 2013-10-07 21:59:25Z 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 "HostDnsService.h"
|
---|
26 | #include <iprt/thread.h>
|
---|
27 | #include <iprt/semaphore.h>
|
---|
28 |
|
---|
29 | HostDnsService::HostDnsService(){}
|
---|
30 |
|
---|
31 | HostDnsService::~HostDnsService ()
|
---|
32 | {
|
---|
33 | int rc = RTCritSectDelete(&m_hCritSect);
|
---|
34 | AssertRC(rc);
|
---|
35 | }
|
---|
36 |
|
---|
37 |
|
---|
38 | HRESULT HostDnsService::init(const VirtualBox *aParent)
|
---|
39 | {
|
---|
40 | mParent = aParent;
|
---|
41 |
|
---|
42 | int rc = RTCritSectInit(&m_hCritSect);
|
---|
43 | AssertRCReturn(rc, E_FAIL);
|
---|
44 | return S_OK;
|
---|
45 | }
|
---|
46 |
|
---|
47 | HRESULT HostDnsService::start()
|
---|
48 | {
|
---|
49 | return S_OK;
|
---|
50 | }
|
---|
51 |
|
---|
52 | void HostDnsService::stop()
|
---|
53 | {
|
---|
54 | }
|
---|
55 |
|
---|
56 | HRESULT HostDnsService::update()
|
---|
57 | {
|
---|
58 | unconst(mParent)->onHostNameResolutionConfigurationChange();
|
---|
59 | return S_OK;
|
---|
60 | }
|
---|
61 |
|
---|
62 | STDMETHODIMP HostDnsService::COMGETTER(NameServers)(ComSafeArrayOut(BSTR, aNameServers))
|
---|
63 | {
|
---|
64 | RTCritSectEnter(&m_hCritSect);
|
---|
65 | com::SafeArray<BSTR> nameServers(m_llNameServers.size());
|
---|
66 |
|
---|
67 | Utf8StrListIterator it;
|
---|
68 | int i = 0;
|
---|
69 | for (it = m_llNameServers.begin(); it != m_llNameServers.end(); ++it, ++i)
|
---|
70 | (*it).cloneTo(&nameServers[i]);
|
---|
71 |
|
---|
72 | nameServers.detachTo(ComSafeArrayOutArg(aNameServers));
|
---|
73 |
|
---|
74 | RTCritSectLeave(&m_hCritSect);
|
---|
75 |
|
---|
76 | return S_OK;
|
---|
77 | }
|
---|
78 |
|
---|
79 |
|
---|
80 | STDMETHODIMP HostDnsService::COMGETTER(DomainName)(BSTR *aDomainName)
|
---|
81 | {
|
---|
82 | RTCritSectEnter(&m_hCritSect);
|
---|
83 |
|
---|
84 | m_DomainName.cloneTo(aDomainName);
|
---|
85 |
|
---|
86 | RTCritSectLeave(&m_hCritSect);
|
---|
87 |
|
---|
88 | return S_OK;
|
---|
89 | }
|
---|
90 |
|
---|
91 |
|
---|
92 | STDMETHODIMP HostDnsService::COMGETTER(SearchStrings)(ComSafeArrayOut(BSTR, aSearchStrings))
|
---|
93 | {
|
---|
94 | RTCritSectEnter(&m_hCritSect);
|
---|
95 |
|
---|
96 | com::SafeArray<BSTR> searchString(m_llSearchStrings.size());
|
---|
97 |
|
---|
98 | Utf8StrListIterator it;
|
---|
99 | int i = 0;
|
---|
100 | for (it = m_llSearchStrings.begin(); it != m_llSearchStrings.end(); ++it, ++i)
|
---|
101 | (*it).cloneTo(&searchString[i]);
|
---|
102 |
|
---|
103 |
|
---|
104 | searchString.detachTo(ComSafeArrayOutArg(aSearchStrings));
|
---|
105 |
|
---|
106 | RTCritSectLeave(&m_hCritSect);
|
---|
107 |
|
---|
108 | return S_OK;
|
---|
109 | }
|
---|
110 |
|
---|