winealsa: Use dedicated macros to call interface functions.
[wine.git] / dlls / tapi32 / assisted.c
blob298087de71e6509b5e26c23fda1d1ebfd14d57b7
1 /*
2 * TAPI32 Assisted Telephony
4 * Copyright 1999 Andreas Mohr
5 * Copyright 2011 André Hentschel
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library 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 GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include <stdarg.h>
23 #include <stdio.h>
24 #include "windef.h"
25 #include "winbase.h"
26 #include "wingdi.h"
27 #include "winreg.h"
28 #include "objbase.h"
29 #include "tapi.h"
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(tapi);
34 /***********************************************************************
35 * tapiGetLocationInfoW (TAPI32.@)
37 DWORD WINAPI tapiGetLocationInfoW(LPWSTR countrycode, LPWSTR citycode)
39 HKEY hkey, hsubkey;
40 DWORD currid;
41 DWORD valsize;
42 DWORD type;
43 DWORD bufsize;
44 BYTE buf[200];
45 WCHAR szlockey[20];
47 static const WCHAR currentidW[] = {'C','u','r','r','e','n','t','I','D',0};
48 static const WCHAR locationW[] = {'L','o','c','a','t','i','o','n','%','u',0};
49 static const WCHAR areacodeW[] = {'A','r','e','a','C','o','d','e',0};
50 static const WCHAR countryW[] = {'C','o','u','n','t','r','y',0};
51 static const WCHAR fmtW[] = {'%','u',0};
53 static const WCHAR locations_keyW[] =
54 {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
55 'W','i','n','d','o','w','s','\\',
56 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
57 'T','e','l','e','p','h','o','n','y','\\','L','o','c','a','t','i','o','n','s',0};
59 if(RegOpenKeyW(HKEY_LOCAL_MACHINE, locations_keyW, &hkey) == ERROR_SUCCESS) {
60 valsize = sizeof( DWORD);
61 if(!RegQueryValueExW(hkey, currentidW, 0, &type, (LPBYTE) &currid, &valsize) &&
62 type == REG_DWORD) {
63 /* find a subkey called Location1, Location2... */
64 swprintf( szlockey, ARRAY_SIZE(szlockey), locationW, currid);
65 if( !RegOpenKeyW( hkey, szlockey, &hsubkey)) {
66 if( citycode) {
67 bufsize=sizeof(buf);
68 if( !RegQueryValueExW( hsubkey, areacodeW, 0, &type, buf, &bufsize) &&
69 type == REG_SZ) {
70 lstrcpynW( citycode, (WCHAR *) buf, 8);
71 } else
72 citycode[0] = '\0';
74 if( countrycode) {
75 bufsize=sizeof(buf);
76 if( !RegQueryValueExW( hsubkey, countryW, 0, &type, buf, &bufsize) &&
77 type == REG_DWORD)
78 swprintf( countrycode, 8, fmtW, *(LPDWORD) buf );
79 else
80 countrycode[0] = '\0';
82 TRACE("(%p \"%s\", %p \"%s\"): success.\n", countrycode, debugstr_w(countrycode),
83 citycode, debugstr_w(citycode));
84 RegCloseKey( hkey);
85 RegCloseKey( hsubkey);
86 return 0; /* SUCCESS */
89 RegCloseKey( hkey);
91 WARN("(%p, %p): failed (no telephony registry entries?).\n", countrycode, citycode);
92 return TAPIERR_REQUESTFAILED;
96 /***********************************************************************
97 * tapiGetLocationInfoA (TAPI32.@)
99 DWORD WINAPI tapiGetLocationInfoA(LPSTR countrycode, LPSTR citycode)
101 DWORD ret, len;
102 LPWSTR country, city;
104 len = MultiByteToWideChar( CP_ACP, 0, countrycode, -1, NULL, 0 );
105 country = HeapAlloc( GetProcessHeap(), 0, len );
106 MultiByteToWideChar( CP_ACP, 0, countrycode, -1, country, len );
108 len = MultiByteToWideChar( CP_ACP, 0, citycode, -1, NULL, 0 );
109 city = HeapAlloc( GetProcessHeap(), 0, len );
110 MultiByteToWideChar( CP_ACP, 0, citycode, -1, city, len );
112 ret = tapiGetLocationInfoW(country, city);
114 HeapFree( GetProcessHeap(), 0, city );
115 HeapFree( GetProcessHeap(), 0, country );
116 return ret;
119 /***********************************************************************
120 * tapiRequestMakeCall (TAPI32.@)
122 DWORD WINAPI tapiRequestMakeCallA(LPCSTR lpszDestAddress, LPCSTR lpszAppName,
123 LPCSTR lpszCalledParty, LPCSTR lpszComment)
125 FIXME("(%s, %s, %s, %s): stub.\n", lpszDestAddress, lpszAppName, lpszCalledParty, lpszComment);
126 return 0;