Exemplo n.º 1
0
static
ULONG
WINAPI
INetConnectionPropertyUi2_fnRelease(
    INetConnectionPropertyUi2 * iface)
{
    INetConnectionPropertyUiImpl * This =  (INetConnectionPropertyUiImpl*)iface;
    ULONG refCount = InterlockedDecrement(&This->ref);

    if (!refCount) 
    {
        if (This->pNCfg)
        {
            INetCfg_Uninitialize(This->pNCfg);
            INetCfg_Release(This->pNCfg);
        }
        if (This->NCfgLock)
        {
            INetCfgLock_Release(This->NCfgLock);
        }
        if (This->pProperties)
        {
            NcFreeNetconProperties(This->pProperties);
        }
        CoTaskMemFree (This);
    }
    return refCount;
}
Exemplo n.º 2
0
static void create_configuration(void)
{
    static const WCHAR tcpipW[] = {'M','S','_','T','C','P','I','P',0};
    static const WCHAR myclient[] = {'M','Y',' ','C','L','I','E','N','T',0};
    HRESULT hr;
    INetCfg *config = NULL;
    INetCfgLock *netlock = NULL;
    INetCfgComponent *component = NULL;
    LPWSTR client = NULL;

    hr = CoCreateInstance( &CLSID_CNetCfg, NULL, CLSCTX_ALL, &IID_INetCfg, (LPVOID*)&config);
    ok(hr == S_OK, "Failed to create object\n");
    if(SUCCEEDED(hr))
    {
        hr = INetCfg_QueryInterface(config, &IID_INetCfgLock, (LPVOID*)&netlock);
        ok(hr == S_OK, "got 0x%08x\n", hr);

        hr = INetCfgLock_AcquireWriteLock(netlock, 5000, myclient, &client);
        ok(hr == S_OK ||
           hr == E_ACCESSDENIED /* Not run as admin */, "got 0x%08x\n", hr);
        if(hr == S_OK)
        {
            trace("Lock value: %s\n", wine_dbgstr_w(client));
            CoTaskMemFree(client);
        }
        else if(hr == E_ACCESSDENIED)
            trace("Not run with Admin permissions\n");

        hr = INetCfg_Initialize(config, NULL);
        ok(hr == S_OK, "got 0x%08x\n", hr);

        /* AcquireWriteLock needs to be run before Initialize */
        hr = INetCfgLock_AcquireWriteLock(netlock, 5000, myclient, &client);
        todo_wine ok(hr == NETCFG_E_ALREADY_INITIALIZED || hr == E_ACCESSDENIED, "got 0x%08x\n", hr);

        hr =  INetCfg_FindComponent(config, tcpipW, &component);
        todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
        if(hr == S_OK)
        {
            INetCfgComponent_Release(component);
        }

        hr = INetCfg_Apply(config);
        todo_wine ok(hr == S_OK || hr == NETCFG_E_NO_WRITE_LOCK, "got 0x%08x\n", hr);

        hr = INetCfg_Uninitialize(config);
        ok(hr == S_OK, "got 0x%08x\n", hr);

        hr = INetCfgLock_ReleaseWriteLock(netlock);
        ok(hr == S_OK, "got 0x%08x\n", hr);

        INetCfg_Release(config);
    }
}
Exemplo n.º 3
0
VOID
InitializeLANPropertiesUIDlg(HWND hwndDlg, INetConnectionPropertyUiImpl * This)
{
    HRESULT hr;
    INetCfg * pNCfg;
    INetCfgLock * pNCfgLock;
    HWND hDlgCtrl = GetDlgItem(hwndDlg, IDC_COMPONENTSLIST);
    LVCOLUMNW lc;
    RECT rc;
    DWORD dwStyle;
    LPWSTR pDisplayName;
    LVITEMW li;

    SendDlgItemMessageW(hwndDlg, IDC_NETCARDNAME, WM_SETTEXT, 0, (LPARAM)This->pProperties->pszwDeviceName);
    if (This->pProperties->dwCharacter & NCCF_SHOW_ICON)
    {
        /* check show item on taskbar*/
        SendDlgItemMessageW(hwndDlg, IDC_SHOWTASKBAR, BM_SETCHECK, BST_CHECKED, 0);
    }
    if (This->pProperties->dwCharacter & NCCF_NOTIFY_DISCONNECTED)
    {
        /* check notify item */
        SendDlgItemMessageW(hwndDlg, IDC_NOTIFYNOCONNECTION, BM_SETCHECK, BST_CHECKED, 0);
    }

    memset(&lc, 0, sizeof(LV_COLUMN));
    lc.mask = LVCF_TEXT | LVCF_SUBITEM | LVCF_FMT;
    lc.fmt = LVCFMT_FIXED_WIDTH;
    if (GetClientRect(hDlgCtrl, &rc))
    {
        lc.mask |= LVCF_WIDTH;
        lc.cx = rc.right - rc.left;
    }
    lc.pszText    = L"";
    (void)SendMessageW(hDlgCtrl, LVM_INSERTCOLUMNW, 0, (LPARAM)&lc);
    dwStyle = (DWORD) SendMessage(hDlgCtrl, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
    dwStyle = dwStyle | LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES;
    SendMessage(hDlgCtrl, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, dwStyle);



    hr = CoCreateInstance(&CLSID_CNetCfg, NULL, CLSCTX_INPROC_SERVER, &IID_INetCfg, (LPVOID*)&pNCfg);
    if (FAILED(hr))
        return;

    hr = INetCfgLock_QueryInterface(pNCfg, &IID_INetCfgLock, (LPVOID*)&pNCfgLock);
    hr = INetCfgLock_AcquireWriteLock(pNCfgLock, 100, L"", &pDisplayName);
    if (hr == S_FALSE)
    {
        CoTaskMemFree(pDisplayName);
        return;
    }

    This->NCfgLock = pNCfgLock;
    hr = INetCfg_Initialize(pNCfg, NULL);
    if (FAILED(hr))
    {
        INetCfg_Release(pNCfg);
        return;
    }

    EnumComponents(hDlgCtrl, This, pNCfg, &GUID_DEVCLASS_NETCLIENT, NET_TYPE_CLIENT);
    EnumComponents(hDlgCtrl, This, pNCfg, &GUID_DEVCLASS_NETSERVICE, NET_TYPE_SERVICE);
    EnumComponents(hDlgCtrl, This, pNCfg, &GUID_DEVCLASS_NETTRANS, NET_TYPE_PROTOCOL);
    This->pNCfg = pNCfg;

    ZeroMemory(&li, sizeof(li));
    li.mask = LVIF_STATE;
    li.stateMask = (UINT)-1;
    li.state = LVIS_FOCUSED|LVIS_SELECTED;
    (void)SendMessageW(hDlgCtrl, LVM_SETITEMW, 0, (LPARAM)&li);
}
Exemplo n.º 4
0
VOID
EnumComponents(HWND hDlgCtrl, INetConnectionPropertyUiImpl * This, INetCfg * pNCfg, const GUID * CompGuid, UINT Type)
{
    HRESULT hr;
    IEnumNetCfgComponent * pENetCfg;
    INetCfgComponent  *pNCfgComp, *pAdapterCfgComp;
    INetCfgComponentBindings * pCompBind;
    ULONG Num;
    DWORD dwCharacteristics;
    LPOLESTR pDisplayName, pHelpText;
    PNET_ITEM pItem;
    BOOL bChecked;

    hr = INetCfg_EnumComponents(pNCfg, CompGuid, &pENetCfg);
    if (FAILED(hr))
    {
        INetCfg_Release(pNCfg);
        return;
    }
    while(IEnumNetCfgComponent_Next(pENetCfg, 1, &pNCfgComp, &Num) == S_OK)
    {
          hr = INetCfgComponent_GetCharacteristics(pNCfgComp, &dwCharacteristics);
          if (SUCCEEDED(hr) && (dwCharacteristics & NCF_HIDDEN))
          {
              INetCfgComponent_Release(pNCfgComp);
              continue;
          }
          pDisplayName = NULL;
          pHelpText = NULL;
          hr = INetCfgComponent_GetDisplayName(pNCfgComp, &pDisplayName);
          hr = INetCfgComponent_GetHelpText(pNCfgComp, &pHelpText);
          bChecked = TRUE; //Odyssey hack
          hr = INetCfgComponent_QueryInterface(pNCfgComp, &IID_INetCfgComponentBindings, (LPVOID*)&pCompBind);
          if (SUCCEEDED(hr))
          {
              if (GetINetCfgComponent(pNCfg, This, &pAdapterCfgComp))
              {
                  hr = INetCfgComponentBindings_IsBoundTo(pCompBind, pAdapterCfgComp);
                  if (hr == S_OK)
                      bChecked = TRUE;
                  else
                      bChecked = FALSE;
                  INetCfgComponent_Release(pAdapterCfgComp);
                  INetCfgComponentBindings_Release(pCompBind);
              }
          }
          pItem = CoTaskMemAlloc(sizeof(NET_ITEM));
          if (!pItem)
              continue;
          pItem->dwCharacteristics = dwCharacteristics;
          pItem->szHelp = pHelpText;
          pItem->Type = Type;
          pItem->pNCfgComp = pNCfgComp;
          pItem->NumPropDialogOpen = 0;


          AddItemToListView(hDlgCtrl, pItem, pDisplayName, bChecked);
          CoTaskMemFree(pDisplayName);
    }
    IEnumNetCfgComponent_Release(pENetCfg);
}