shell/Windows: Convert tabs to space
authorJocelyn Turcotte <jturcotte@woboq.com>
Thu, 5 Jan 2017 16:28:28 +0000 (17:28 +0100)
committerJocelyn Turcotte <jturcotte@woboq.com>
Wed, 18 Jan 2017 11:15:52 +0000 (12:15 +0100)
It was a mix of both and the rest of the code uses spaces.

28 files changed:
shell_integration/windows/OCContextMenu/OCClientInterface.cpp
shell_integration/windows/OCContextMenu/OCClientInterface.h
shell_integration/windows/OCContextMenu/OCContextMenu.cpp
shell_integration/windows/OCContextMenu/OCContextMenuFactory.cpp
shell_integration/windows/OCContextMenu/OCContextMenuFactory.h
shell_integration/windows/OCContextMenu/OCContextMenuRegHandler.cpp
shell_integration/windows/OCContextMenu/OCContextMenuRegHandler.h
shell_integration/windows/OCOverlays/DllMain.cpp
shell_integration/windows/OCOverlays/OCOverlay.cpp
shell_integration/windows/OCOverlays/OCOverlay.h
shell_integration/windows/OCOverlays/OCOverlayFactory.cpp
shell_integration/windows/OCOverlays/OCOverlayFactory.h
shell_integration/windows/OCOverlays/OCOverlayRegistrationHandler.cpp
shell_integration/windows/OCOverlays/OCOverlayRegistrationHandler.h
shell_integration/windows/OCOverlays/OverlayConstants.h
shell_integration/windows/OCUtil/CommunicationSocket.cpp
shell_integration/windows/OCUtil/CommunicationSocket.h
shell_integration/windows/OCUtil/FileUtil.cpp
shell_integration/windows/OCUtil/FileUtil.h
shell_integration/windows/OCUtil/OCMessage.cpp
shell_integration/windows/OCUtil/OCMessage.h
shell_integration/windows/OCUtil/ParserUtil.cpp
shell_integration/windows/OCUtil/RegistryUtil.cpp
shell_integration/windows/OCUtil/RegistryUtil.h
shell_integration/windows/OCUtil/RemotePathChecker.cpp
shell_integration/windows/OCUtil/RemotePathChecker.h
shell_integration/windows/OCUtil/StringUtil.cpp
shell_integration/windows/OCUtil/StringUtil.h

index 0ddf663ee554d9d5b4afd93efd3d9717359f7c97..05b23ec09aa875ec37687cf7e88b970620f5443b 100644 (file)
@@ -36,54 +36,54 @@ using namespace std;
 
 OCClientInterface::ContextMenuInfo OCClientInterface::FetchInfo()
 {
-       auto pipename = CommunicationSocket::DefaultPipePath();
+    auto pipename = CommunicationSocket::DefaultPipePath();
 
-       CommunicationSocket socket;
-       if (!WaitNamedPipe(pipename.data(), PIPE_TIMEOUT)) {
-               return {};
-       }
-       if (!socket.Connect(pipename)) {
-               return {};
-       }
-       socket.SendMsg(L"SHARE_MENU_TITLE\n");
+    CommunicationSocket socket;
+    if (!WaitNamedPipe(pipename.data(), PIPE_TIMEOUT)) {
+        return {};
+    }
+    if (!socket.Connect(pipename)) {
+        return {};
+    }
+    socket.SendMsg(L"SHARE_MENU_TITLE\n");
 
-       ContextMenuInfo info;
-       std::wstring response;
-       int sleptCount = 0;
-       while (sleptCount < 5) {
-               if (socket.ReadLine(&response)) {
-                       if (StringUtil::begins_with(response, wstring(L"REGISTER_PATH:"))) {
-                               wstring responsePath = response.substr(14); // length of REGISTER_PATH
-                               info.watchedDirectories.push_back(responsePath);
-                       }
-                       else if (StringUtil::begins_with(response, wstring(L"SHARE_MENU_TITLE:"))) {
-                               info.shareMenuTitle = response.substr(17); // length of SHARE_MENU_TITLE:
-                               break; // Stop once we received the last sent request
-                       }
-               }
-               else {
-                       Sleep(50);
-                       ++sleptCount;
-               }
-       }
-       return info;
+    ContextMenuInfo info;
+    std::wstring response;
+    int sleptCount = 0;
+    while (sleptCount < 5) {
+        if (socket.ReadLine(&response)) {
+            if (StringUtil::begins_with(response, wstring(L"REGISTER_PATH:"))) {
+                wstring responsePath = response.substr(14); // length of REGISTER_PATH
+                info.watchedDirectories.push_back(responsePath);
+            }
+            else if (StringUtil::begins_with(response, wstring(L"SHARE_MENU_TITLE:"))) {
+                info.shareMenuTitle = response.substr(17); // length of SHARE_MENU_TITLE:
+                break; // Stop once we received the last sent request
+            }
+        }
+        else {
+            Sleep(50);
+            ++sleptCount;
+        }
+    }
+    return info;
 }
 
 void OCClientInterface::ShareObject(const std::wstring &path)
 {
-       auto pipename = CommunicationSocket::DefaultPipePath();
+    auto pipename = CommunicationSocket::DefaultPipePath();
 
-       CommunicationSocket socket;
-       if (!WaitNamedPipe(pipename.data(), PIPE_TIMEOUT)) {
-               return;
-       }
-       if (!socket.Connect(pipename)) {
-               return;
-       }
+    CommunicationSocket socket;
+    if (!WaitNamedPipe(pipename.data(), PIPE_TIMEOUT)) {
+        return;
+    }
+    if (!socket.Connect(pipename)) {
+        return;
+    }
 
-       wchar_t msg[SOCK_BUFFER] = { 0 };
-       if (SUCCEEDED(StringCchPrintf(msg, SOCK_BUFFER, L"SHARE:%s\n", path.c_str())))
-       {
-               socket.SendMsg(msg);
-       }
+    wchar_t msg[SOCK_BUFFER] = { 0 };
+    if (SUCCEEDED(StringCchPrintf(msg, SOCK_BUFFER, L"SHARE:%s\n", path.c_str())))
+    {
+        socket.SendMsg(msg);
+    }
 }
index f7725fd676a866f708db8ec27681b28908d99c15..00d4470eafd0e1563fd32ef7cbd6e3ebb45a61a2 100644 (file)
@@ -43,12 +43,12 @@ class CommunicationSocket;
 class OCClientInterface
 {
 public:
-       struct ContextMenuInfo {
-               std::vector<std::wstring> watchedDirectories;
-               std::wstring shareMenuTitle;
-       };
-       static ContextMenuInfo FetchInfo();
-       static void ShareObject(const std::wstring &path);
+    struct ContextMenuInfo {
+        std::vector<std::wstring> watchedDirectories;
+        std::wstring shareMenuTitle;
+    };
+    static ContextMenuInfo FetchInfo();
+    static void ShareObject(const std::wstring &path);
 };
 
 #endif //ABSTRACTSOCKETHANDLER_H
index 43aede242d1906f7ac2b3350125ab29c61337633..65ff203e1d941b701c0d42bc09e4b47f4242d558 100644 (file)
@@ -30,27 +30,27 @@ extern long g_cDllRef;
 
 
 OCContextMenu::OCContextMenu(void) 
-       : m_cRef(1)
-       , m_pszMenuText(L"&Share")
-       , m_pszVerb("ocshare")
-       , m_pwszVerb(L"ocshare")
-       , m_pszVerbCanonicalName("OCShareViaOC")
-       , m_pwszVerbCanonicalName(L"OCShareViaOC")
-       , m_pszVerbHelpText("Share via ownCloud")
-       , m_pwszVerbHelpText(L"Share via ownCloud")
+    : m_cRef(1)
+    , m_pszMenuText(L"&Share")
+    , m_pszVerb("ocshare")
+    , m_pwszVerb(L"ocshare")
+    , m_pszVerbCanonicalName("OCShareViaOC")
+    , m_pwszVerbCanonicalName(L"OCShareViaOC")
+    , m_pszVerbHelpText("Share via ownCloud")
+    , m_pwszVerbHelpText(L"Share via ownCloud")
 {
-       InterlockedIncrement(&g_cDllRef);
+    InterlockedIncrement(&g_cDllRef);
 }
 
 OCContextMenu::~OCContextMenu(void)
 {
-       InterlockedDecrement(&g_cDllRef);
+    InterlockedDecrement(&g_cDllRef);
 }
 
 
 void OCContextMenu::OnVerbDisplayFileName(HWND hWnd)
 {
-       OCClientInterface::ShareObject(std::wstring(m_szSelectedFile));
+    OCClientInterface::ShareObject(std::wstring(m_szSelectedFile));
 }
 
 
@@ -59,30 +59,30 @@ void OCContextMenu::OnVerbDisplayFileName(HWND hWnd)
 // Query to the interface the component supported.
 IFACEMETHODIMP OCContextMenu::QueryInterface(REFIID riid, void **ppv)
 {
-       static const QITAB qit[] =
-       {
-               QITABENT(OCContextMenu, IContextMenu),
-               QITABENT(OCContextMenu, IShellExtInit),
-               { 0 },
-       };
-       return QISearch(this, qit, riid, ppv);
+    static const QITAB qit[] =
+    {
+        QITABENT(OCContextMenu, IContextMenu),
+        QITABENT(OCContextMenu, IShellExtInit),
+        { 0 },
+    };
+    return QISearch(this, qit, riid, ppv);
 }
 
 // Increase the reference count for an interface on an object.
 IFACEMETHODIMP_(ULONG) OCContextMenu::AddRef()
 {
-       return InterlockedIncrement(&m_cRef);
+    return InterlockedIncrement(&m_cRef);
 }
 
 // Decrease the reference count for an interface on an object.
 IFACEMETHODIMP_(ULONG) OCContextMenu::Release()
 {
-       ULONG cRef = InterlockedDecrement(&m_cRef);
-       if (0 == cRef) {
-               delete this;
-       }
+    ULONG cRef = InterlockedDecrement(&m_cRef);
+    if (0 == cRef) {
+        delete this;
+    }
 
-       return cRef;
+    return cRef;
 }
 
 #pragma endregion
@@ -92,40 +92,40 @@ IFACEMETHODIMP_(ULONG) OCContextMenu::Release()
 
 // Initialize the context menu handler.
 IFACEMETHODIMP OCContextMenu::Initialize(
-       LPCITEMIDLIST pidlFolder, LPDATAOBJECT pDataObj, HKEY hKeyProgID)
+    LPCITEMIDLIST pidlFolder, LPDATAOBJECT pDataObj, HKEY hKeyProgID)
 {
-       if (!pDataObj) {
-               return E_INVALIDARG;
-       }
-
-       HRESULT hr = E_FAIL;
-
-       FORMATETC fe = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
-       STGMEDIUM stm;
-
-       if (SUCCEEDED(pDataObj->GetData(&fe, &stm))) {
-               // Get an HDROP handle.
-               HDROP hDrop = static_cast<HDROP>(GlobalLock(stm.hGlobal));
-               if (hDrop) {
-                       // Ignore multi-selections
-                       UINT nFiles = DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0);
-                       if (nFiles == 1) {
-                               // Get the path of the file.
-                               if (0 != DragQueryFile(hDrop, 0, m_szSelectedFile,      ARRAYSIZE(m_szSelectedFile)))
-                               {
-                                       hr = S_OK;
-                               }
-                       }
-
-                       GlobalUnlock(stm.hGlobal);
-               }
-
-               ReleaseStgMedium(&stm);
-       }
-
-       // If any value other than S_OK is returned from the method, the context 
-       // menu item is not displayed.
-       return hr;
+    if (!pDataObj) {
+        return E_INVALIDARG;
+    }
+
+    HRESULT hr = E_FAIL;
+
+    FORMATETC fe = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
+    STGMEDIUM stm;
+
+    if (SUCCEEDED(pDataObj->GetData(&fe, &stm))) {
+        // Get an HDROP handle.
+        HDROP hDrop = static_cast<HDROP>(GlobalLock(stm.hGlobal));
+        if (hDrop) {
+            // Ignore multi-selections
+            UINT nFiles = DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0);
+            if (nFiles == 1) {
+                // Get the path of the file.
+                if (0 != DragQueryFile(hDrop, 0, m_szSelectedFile,  ARRAYSIZE(m_szSelectedFile)))
+                {
+                    hr = S_OK;
+                }
+            }
+
+            GlobalUnlock(stm.hGlobal);
+        }
+
+        ReleaseStgMedium(&stm);
+    }
+
+    // If any value other than S_OK is returned from the method, the context 
+    // menu item is not displayed.
+    return hr;
 }
 
 #pragma endregion
@@ -135,135 +135,135 @@ IFACEMETHODIMP OCContextMenu::Initialize(
 
 void InsertSeperator(HMENU hMenu, UINT indexMenu)
 {
-       // Add a separator.
-       MENUITEMINFO sep = { sizeof(sep) };
-       sep.fMask = MIIM_TYPE;
-       sep.fType = MFT_SEPARATOR;
-       InsertMenuItem(hMenu, indexMenu, TRUE, &sep);
+    // Add a separator.
+    MENUITEMINFO sep = { sizeof(sep) };
+    sep.fMask = MIIM_TYPE;
+    sep.fType = MFT_SEPARATOR;
+    InsertMenuItem(hMenu, indexMenu, TRUE, &sep);
 }
 
 IFACEMETHODIMP OCContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags)
 {
-       // If uFlags include CMF_DEFAULTONLY then we should not do anything.
-       if (CMF_DEFAULTONLY & uFlags)
-       {
-               return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(0));
-       }
-
-       OCClientInterface::ContextMenuInfo info = OCClientInterface::FetchInfo();
-       bool skip = true;
-       for (const std::wstring path : info.watchedDirectories) {
-               if (StringUtil::begins_with(std::wstring(m_szSelectedFile), path)) {
-                       skip = false;
-                       break;
-               }
-       }
-
-       if (skip) {
-               return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(0));
-       }
-
-       InsertSeperator(hMenu, indexMenu);
-       indexMenu++;
-
-       assert(!info.shareMenuTitle.empty());
-       MENUITEMINFO mii = { sizeof(mii) };
-       mii.fMask = MIIM_STRING | MIIM_FTYPE | MIIM_ID | MIIM_STATE;
-       mii.wID = idCmdFirst + IDM_SHARE;
-       mii.fType = MFT_STRING;
-       mii.dwTypeData = &info.shareMenuTitle[0];
-       mii.fState = MFS_ENABLED;
-       if (!InsertMenuItem(hMenu, indexMenu, TRUE, &mii))
-       {
-               return HRESULT_FROM_WIN32(GetLastError());
-       }
-
-       indexMenu++;
-       InsertSeperator(hMenu, indexMenu);
-
-
-       // Return an HRESULT value with the severity set to SEVERITY_SUCCESS. 
-       // Set the code value to the offset of the largest command identifier 
-       // that was assigned, plus one (1).
-       return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(IDM_SHARE + 1));
+    // If uFlags include CMF_DEFAULTONLY then we should not do anything.
+    if (CMF_DEFAULTONLY & uFlags)
+    {
+        return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(0));
+    }
+
+    OCClientInterface::ContextMenuInfo info = OCClientInterface::FetchInfo();
+    bool skip = true;
+    for (const std::wstring path : info.watchedDirectories) {
+        if (StringUtil::begins_with(std::wstring(m_szSelectedFile), path)) {
+            skip = false;
+            break;
+        }
+    }
+
+    if (skip) {
+        return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(0));
+    }
+
+    InsertSeperator(hMenu, indexMenu);
+    indexMenu++;
+
+    assert(!info.shareMenuTitle.empty());
+    MENUITEMINFO mii = { sizeof(mii) };
+    mii.fMask = MIIM_STRING | MIIM_FTYPE | MIIM_ID | MIIM_STATE;
+    mii.wID = idCmdFirst + IDM_SHARE;
+    mii.fType = MFT_STRING;
+    mii.dwTypeData = &info.shareMenuTitle[0];
+    mii.fState = MFS_ENABLED;
+    if (!InsertMenuItem(hMenu, indexMenu, TRUE, &mii))
+    {
+        return HRESULT_FROM_WIN32(GetLastError());
+    }
+
+    indexMenu++;
+    InsertSeperator(hMenu, indexMenu);
+
+
+    // Return an HRESULT value with the severity set to SEVERITY_SUCCESS. 
+    // Set the code value to the offset of the largest command identifier 
+    // that was assigned, plus one (1).
+    return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(IDM_SHARE + 1));
 }
 
 IFACEMETHODIMP OCContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO pici)
 {
 
-       // For the Unicode case, if the high-order word is not zero, the 
-       // command's verb string is in lpcmi->lpVerbW. 
-       if (HIWORD(((CMINVOKECOMMANDINFOEX*)pici)->lpVerbW))
-       {
-               // Is the verb supported by this context menu extension?
-               if (StrCmpIW(((CMINVOKECOMMANDINFOEX*)pici)->lpVerbW, m_pwszVerb) == 0)
-               {
-                       OnVerbDisplayFileName(pici->hwnd);
-               }
-               else
-               {
-                       // If the verb is not recognized by the context menu handler, it 
-                       // must return E_FAIL to allow it to be passed on to the other 
-                       // context menu handlers that might implement that verb.
-                       return E_FAIL;
-               }
-       }
-
-       // If the command cannot be identified through the verb string, then 
-       // check the identifier offset.
-       else
-       {
-               // Is the command identifier offset supported by this context menu 
-               // extension?
-               if (LOWORD(pici->lpVerb) == IDM_SHARE)
-               {
-                       OnVerbDisplayFileName(pici->hwnd);
-               }
-               else
-               {
-                       // If the verb is not recognized by the context menu handler, it 
-                       // must return E_FAIL to allow it to be passed on to the other 
-                       // context menu handlers that might implement that verb.
-                       return E_FAIL;
-               }
-       }
-
-       return S_OK;
+    // For the Unicode case, if the high-order word is not zero, the 
+    // command's verb string is in lpcmi->lpVerbW. 
+    if (HIWORD(((CMINVOKECOMMANDINFOEX*)pici)->lpVerbW))
+    {
+        // Is the verb supported by this context menu extension?
+        if (StrCmpIW(((CMINVOKECOMMANDINFOEX*)pici)->lpVerbW, m_pwszVerb) == 0)
+        {
+            OnVerbDisplayFileName(pici->hwnd);
+        }
+        else
+        {
+            // If the verb is not recognized by the context menu handler, it 
+            // must return E_FAIL to allow it to be passed on to the other 
+            // context menu handlers that might implement that verb.
+            return E_FAIL;
+        }
+    }
+
+    // If the command cannot be identified through the verb string, then 
+    // check the identifier offset.
+    else
+    {
+        // Is the command identifier offset supported by this context menu 
+        // extension?
+        if (LOWORD(pici->lpVerb) == IDM_SHARE)
+        {
+            OnVerbDisplayFileName(pici->hwnd);
+        }
+        else
+        {
+            // If the verb is not recognized by the context menu handler, it 
+            // must return E_FAIL to allow it to be passed on to the other 
+            // context menu handlers that might implement that verb.
+            return E_FAIL;
+        }
+    }
+
+    return S_OK;
 }
 
 IFACEMETHODIMP OCContextMenu::GetCommandString(UINT_PTR idCommand,
-       UINT uFlags, UINT *pwReserved, LPSTR pszName, UINT cchMax)
+    UINT uFlags, UINT *pwReserved, LPSTR pszName, UINT cchMax)
 {
-       HRESULT hr = E_INVALIDARG;
-
-       if (idCommand == IDM_SHARE)
-       {
-               switch (uFlags)
-               {
-               case GCS_HELPTEXTW:
-                       // Only useful for pre-Vista versions of Windows that have a 
-                       // Status bar.
-                       hr = StringCchCopy(reinterpret_cast<PWSTR>(pszName), cchMax,
-                               m_pwszVerbHelpText);
-                       break;
-
-               case GCS_VERBW:
-                       // GCS_VERBW is an optional feature that enables a caller to 
-                       // discover the canonical name for the verb passed in through 
-                       // idCommand.
-                       hr = StringCchCopy(reinterpret_cast<PWSTR>(pszName), cchMax,
-                               m_pwszVerbCanonicalName);
-                       break;
-
-               default:
-                       hr = S_OK;
-               }
-       }
-
-       // If the command (idCommand) is not supported by this context menu 
-       // extension handler, return E_INVALIDARG.
-
-       return hr;
+    HRESULT hr = E_INVALIDARG;
+
+    if (idCommand == IDM_SHARE)
+    {
+        switch (uFlags)
+        {
+        case GCS_HELPTEXTW:
+            // Only useful for pre-Vista versions of Windows that have a 
+            // Status bar.
+            hr = StringCchCopy(reinterpret_cast<PWSTR>(pszName), cchMax,
+                m_pwszVerbHelpText);
+            break;
+
+        case GCS_VERBW:
+            // GCS_VERBW is an optional feature that enables a caller to 
+            // discover the canonical name for the verb passed in through 
+            // idCommand.
+            hr = StringCchCopy(reinterpret_cast<PWSTR>(pszName), cchMax,
+                m_pwszVerbCanonicalName);
+            break;
+
+        default:
+            hr = S_OK;
+        }
+    }
+
+    // If the command (idCommand) is not supported by this context menu 
+    // extension handler, return E_INVALIDARG.
+
+    return hr;
 }
 
 #pragma endregion
\ No newline at end of file
index 07f61f852690af7b3f3a450fbdd9d41e94806259..006a0091a32487faed790b8b9f62067379753927 100644 (file)
@@ -26,12 +26,12 @@ extern long g_cDllRef;
 
 OCContextMenuFactory::OCContextMenuFactory() : m_cRef(1)
 {
-       InterlockedIncrement(&g_cDllRef);
+    InterlockedIncrement(&g_cDllRef);
 }
 
 OCContextMenuFactory::~OCContextMenuFactory()
 {
-       InterlockedDecrement(&g_cDllRef);
+    InterlockedDecrement(&g_cDllRef);
 }
 
 
@@ -39,22 +39,22 @@ OCContextMenuFactory::~OCContextMenuFactory()
 
 IFACEMETHODIMP OCContextMenuFactory::QueryInterface(REFIID riid, void **ppv)
 {
-       static const QITAB qit[] =      { QITABENT(OCContextMenuFactory, IClassFactory), { 0 }, };
-       return QISearch(this, qit, riid, ppv);
+    static const QITAB qit[] =  { QITABENT(OCContextMenuFactory, IClassFactory), { 0 }, };
+    return QISearch(this, qit, riid, ppv);
 }
 
 IFACEMETHODIMP_(ULONG) OCContextMenuFactory::AddRef()
 {
-       return InterlockedIncrement(&m_cRef);
+    return InterlockedIncrement(&m_cRef);
 }
 
 IFACEMETHODIMP_(ULONG) OCContextMenuFactory::Release()
 {
-       ULONG cRef = InterlockedDecrement(&m_cRef);
-       if (0 == cRef) {
-               delete this;
-       }
-       return cRef;
+    ULONG cRef = InterlockedDecrement(&m_cRef);
+    if (0 == cRef) {
+        delete this;
+    }
+    return cRef;
 }
 
 
@@ -62,30 +62,30 @@ IFACEMETHODIMP_(ULONG) OCContextMenuFactory::Release()
 
 IFACEMETHODIMP OCContextMenuFactory::CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppv)
 {
-       HRESULT hr = CLASS_E_NOAGGREGATION;
-
-       // pUnkOuter is used for aggregation. We do not support it in the sample.
-       if (pUnkOuter == NULL) {
-               hr = E_OUTOFMEMORY;
-
-               // Create the COM component.
-               OCContextMenu *pExt = new (std::nothrow) OCContextMenu();
-               if (pExt) {
-                       // Query the specified interface.
-                       hr = pExt->QueryInterface(riid, ppv);
-                       pExt->Release();
-               }
-       }
-
-       return hr;
+    HRESULT hr = CLASS_E_NOAGGREGATION;
+
+    // pUnkOuter is used for aggregation. We do not support it in the sample.
+    if (pUnkOuter == NULL) {
+        hr = E_OUTOFMEMORY;
+
+        // Create the COM component.
+        OCContextMenu *pExt = new (std::nothrow) OCContextMenu();
+        if (pExt) {
+            // Query the specified interface.
+            hr = pExt->QueryInterface(riid, ppv);
+            pExt->Release();
+        }
+    }
+
+    return hr;
 }
 
 IFACEMETHODIMP OCContextMenuFactory::LockServer(BOOL fLock)
 {
-       if (fLock)      {
-               InterlockedIncrement(&g_cDllRef);
-       } else {
-               InterlockedDecrement(&g_cDllRef);
-       }
-       return S_OK;
+    if (fLock)  {
+        InterlockedIncrement(&g_cDllRef);
+    } else {
+        InterlockedDecrement(&g_cDllRef);
+    }
+    return S_OK;
 }
\ No newline at end of file
index 83b0a1d4eb3245a5040a45e63c608c5506c18449..13f4d6759b21f51f4c198812ce7ca7a1c0b57cd3 100644 (file)
 class OCContextMenuFactory : public IClassFactory
 {
 public:
-       // IUnknown
-       IFACEMETHODIMP QueryInterface(REFIID riid, void **ppv);
-       IFACEMETHODIMP_(ULONG) AddRef();
-       IFACEMETHODIMP_(ULONG) Release();
+    // IUnknown
+    IFACEMETHODIMP QueryInterface(REFIID riid, void **ppv);
+    IFACEMETHODIMP_(ULONG) AddRef();
+    IFACEMETHODIMP_(ULONG) Release();
 
-       // IClassFactory
-       IFACEMETHODIMP CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppv);
-       IFACEMETHODIMP LockServer(BOOL fLock);
+    // IClassFactory
+    IFACEMETHODIMP CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppv);
+    IFACEMETHODIMP LockServer(BOOL fLock);
 
-       OCContextMenuFactory();
+    OCContextMenuFactory();
 
 private:
-       ~OCContextMenuFactory();
-       long m_cRef;
+    ~OCContextMenuFactory();
+    long m_cRef;
 };
 
 #endif //OCCONTEXTMENUFACTORY_H
\ No newline at end of file
index 126816d914cda28f5f8e44f83ac058b819e6c4eb..1bbfc66054b237fa7d2e77d4c2c8d14fbf3c560c 100644 (file)
@@ -23,196 +23,196 @@ namespace {
 
 HRESULT SetHKCRRegistryKeyAndValue(PCWSTR pszSubKey, PCWSTR pszValueName, PCWSTR pszData)
 {
-       HRESULT hr;
-       HKEY hKey = NULL;
-
-       // Creates the specified registry key. If the key already exists, the 
-       // function opens it. 
-       hr = HRESULT_FROM_WIN32(RegCreateKeyEx(HKEY_CLASSES_ROOT, pszSubKey, 0,
-               NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL));
-
-       if (SUCCEEDED(hr))
-       {
-               if (pszData != NULL)
-               {
-                       // Set the specified value of the key.
-                       DWORD cbData = lstrlen(pszData) * sizeof(*pszData);
-                       hr = HRESULT_FROM_WIN32(RegSetValueEx(hKey, pszValueName, 0,
-                               REG_SZ, reinterpret_cast<const BYTE *>(pszData), cbData));
-               }
-
-               RegCloseKey(hKey);
-       }
-
-       return hr;
+    HRESULT hr;
+    HKEY hKey = NULL;
+
+    // Creates the specified registry key. If the key already exists, the 
+    // function opens it. 
+    hr = HRESULT_FROM_WIN32(RegCreateKeyEx(HKEY_CLASSES_ROOT, pszSubKey, 0,
+        NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL));
+
+    if (SUCCEEDED(hr))
+    {
+        if (pszData != NULL)
+        {
+            // Set the specified value of the key.
+            DWORD cbData = lstrlen(pszData) * sizeof(*pszData);
+            hr = HRESULT_FROM_WIN32(RegSetValueEx(hKey, pszValueName, 0,
+                REG_SZ, reinterpret_cast<const BYTE *>(pszData), cbData));
+        }
+
+        RegCloseKey(hKey);
+    }
+
+    return hr;
 }
 
 HRESULT GetHKCRRegistryKeyAndValue(PCWSTR pszSubKey, PCWSTR pszValueName, PWSTR pszData, DWORD cbData)
 {
-       HRESULT hr;
-       HKEY hKey = NULL;
+    HRESULT hr;
+    HKEY hKey = NULL;
 
-       // Try to open the specified registry key. 
-       hr = HRESULT_FROM_WIN32(RegOpenKeyEx(HKEY_CLASSES_ROOT, pszSubKey, 0,
-               KEY_READ, &hKey));
+    // Try to open the specified registry key. 
+    hr = HRESULT_FROM_WIN32(RegOpenKeyEx(HKEY_CLASSES_ROOT, pszSubKey, 0,
+        KEY_READ, &hKey));
 
-       if (SUCCEEDED(hr))
-       {
-               // Get the data for the specified value name.
-               hr = HRESULT_FROM_WIN32(RegQueryValueEx(hKey, pszValueName, NULL,
-                       NULL, reinterpret_cast<LPBYTE>(pszData), &cbData));
+    if (SUCCEEDED(hr))
+    {
+        // Get the data for the specified value name.
+        hr = HRESULT_FROM_WIN32(RegQueryValueEx(hKey, pszValueName, NULL,
+            NULL, reinterpret_cast<LPBYTE>(pszData), &cbData));
 
-               RegCloseKey(hKey);
-       }
+        RegCloseKey(hKey);
+    }
 
-       return hr;
+    return hr;
 }
 
 }
 
 HRESULT OCContextMenuRegHandler::RegisterInprocServer(PCWSTR pszModule, const CLSID& clsid, PCWSTR pszFriendlyName, PCWSTR pszThreadModel)
 {
-       if (pszModule == NULL || pszThreadModel == NULL)
-       {
-               return E_INVALIDARG;
-       }
-
-       HRESULT hr;
-
-       wchar_t szCLSID[MAX_PATH];
-       StringFromGUID2(clsid, szCLSID, ARRAYSIZE(szCLSID));
-
-       wchar_t szSubkey[MAX_PATH];
-
-       // Create the HKCR\CLSID\{<CLSID>} key.
-       hr = StringCchPrintf(szSubkey, ARRAYSIZE(szSubkey), L"CLSID\\%s", szCLSID);
-       if (SUCCEEDED(hr))
-       {
-               hr = SetHKCRRegistryKeyAndValue(szSubkey, NULL, pszFriendlyName);
-
-               // Create the HKCR\CLSID\{<CLSID>}\InprocServer32 key.
-               if (SUCCEEDED(hr))
-               {
-                       hr = StringCchPrintf(szSubkey, ARRAYSIZE(szSubkey),
-                               L"CLSID\\%s\\InprocServer32", szCLSID);
-                       if (SUCCEEDED(hr))
-                       {
-                               // Set the default value of the InprocServer32 key to the 
-                               // path of the COM module.
-                               hr = SetHKCRRegistryKeyAndValue(szSubkey, NULL, pszModule);
-                               if (SUCCEEDED(hr))
-                               {
-                                       // Set the threading model of the component.
-                                       hr = SetHKCRRegistryKeyAndValue(szSubkey,
-                                               L"ThreadingModel", pszThreadModel);
-                               }
-                       }
-               }
-       }
-
-       return hr;
+    if (pszModule == NULL || pszThreadModel == NULL)
+    {
+        return E_INVALIDARG;
+    }
+
+    HRESULT hr;
+
+    wchar_t szCLSID[MAX_PATH];
+    StringFromGUID2(clsid, szCLSID, ARRAYSIZE(szCLSID));
+
+    wchar_t szSubkey[MAX_PATH];
+
+    // Create the HKCR\CLSID\{<CLSID>} key.
+    hr = StringCchPrintf(szSubkey, ARRAYSIZE(szSubkey), L"CLSID\\%s", szCLSID);
+    if (SUCCEEDED(hr))
+    {
+        hr = SetHKCRRegistryKeyAndValue(szSubkey, NULL, pszFriendlyName);
+
+        // Create the HKCR\CLSID\{<CLSID>}\InprocServer32 key.
+        if (SUCCEEDED(hr))
+        {
+            hr = StringCchPrintf(szSubkey, ARRAYSIZE(szSubkey),
+                L"CLSID\\%s\\InprocServer32", szCLSID);
+            if (SUCCEEDED(hr))
+            {
+                // Set the default value of the InprocServer32 key to the 
+                // path of the COM module.
+                hr = SetHKCRRegistryKeyAndValue(szSubkey, NULL, pszModule);
+                if (SUCCEEDED(hr))
+                {
+                    // Set the threading model of the component.
+                    hr = SetHKCRRegistryKeyAndValue(szSubkey,
+                        L"ThreadingModel", pszThreadModel);
+                }
+            }
+        }
+    }
+
+    return hr;
 }
 
 HRESULT OCContextMenuRegHandler::UnregisterInprocServer(const CLSID& clsid)
 {
-       HRESULT hr = S_OK;
+    HRESULT hr = S_OK;
 
-       wchar_t szCLSID[MAX_PATH];
-       StringFromGUID2(clsid, szCLSID, ARRAYSIZE(szCLSID));
+    wchar_t szCLSID[MAX_PATH];
+    StringFromGUID2(clsid, szCLSID, ARRAYSIZE(szCLSID));
 
-       wchar_t szSubkey[MAX_PATH];
+    wchar_t szSubkey[MAX_PATH];
 
-       // Delete the HKCR\CLSID\{<CLSID>} key.
-       hr = StringCchPrintf(szSubkey, ARRAYSIZE(szSubkey), L"CLSID\\%s", szCLSID);
-       if (SUCCEEDED(hr))
-       {
-               hr = HRESULT_FROM_WIN32(RegDelnode(HKEY_CLASSES_ROOT, szSubkey));
-       }
+    // Delete the HKCR\CLSID\{<CLSID>} key.
+    hr = StringCchPrintf(szSubkey, ARRAYSIZE(szSubkey), L"CLSID\\%s", szCLSID);
+    if (SUCCEEDED(hr))
+    {
+        hr = HRESULT_FROM_WIN32(RegDelnode(HKEY_CLASSES_ROOT, szSubkey));
+    }
 
-       return hr;
+    return hr;
 }
 
 
 HRESULT OCContextMenuRegHandler::RegisterShellExtContextMenuHandler(
-       PCWSTR pszFileType, const CLSID& clsid, PCWSTR pszFriendlyName)
+    PCWSTR pszFileType, const CLSID& clsid, PCWSTR pszFriendlyName)
 {
-       if (pszFileType == NULL)
-       {
-               return E_INVALIDARG;
-       }
-
-       HRESULT hr;
-
-       wchar_t szCLSID[MAX_PATH];
-       StringFromGUID2(clsid, szCLSID, ARRAYSIZE(szCLSID));
-
-       wchar_t szSubkey[MAX_PATH];
-
-       // If pszFileType starts with '.', try to read the default value of the 
-       // HKCR\<File Type> key which contains the ProgID to which the file type 
-       // is linked.
-       if (*pszFileType == L'.')
-       {
-               wchar_t szDefaultVal[260];
-               hr = GetHKCRRegistryKeyAndValue(pszFileType, NULL, szDefaultVal,
-                       sizeof(szDefaultVal));
-
-               // If the key exists and its default value is not empty, use the 
-               // ProgID as the file type.
-               if (SUCCEEDED(hr) && szDefaultVal[0] != L'\0')
-               {
-                       pszFileType = szDefaultVal;
-               }
-       }
-
-       // Create the key HKCR\<File Type>\shellex\ContextMenuHandlers\{friendlyName>}
-       hr = StringCchPrintf(szSubkey, ARRAYSIZE(szSubkey),
-               L"%s\\shellex\\ContextMenuHandlers\\%s", pszFileType, pszFriendlyName);
-       if (SUCCEEDED(hr))
-       {
-               // Set the default value of the key.
-               hr = SetHKCRRegistryKeyAndValue(szSubkey, NULL, szCLSID);
-       }
-
-       return hr;
+    if (pszFileType == NULL)
+    {
+        return E_INVALIDARG;
+    }
+
+    HRESULT hr;
+
+    wchar_t szCLSID[MAX_PATH];
+    StringFromGUID2(clsid, szCLSID, ARRAYSIZE(szCLSID));
+
+    wchar_t szSubkey[MAX_PATH];
+
+    // If pszFileType starts with '.', try to read the default value of the 
+    // HKCR\<File Type> key which contains the ProgID to which the file type 
+    // is linked.
+    if (*pszFileType == L'.')
+    {
+        wchar_t szDefaultVal[260];
+        hr = GetHKCRRegistryKeyAndValue(pszFileType, NULL, szDefaultVal,
+            sizeof(szDefaultVal));
+
+        // If the key exists and its default value is not empty, use the 
+        // ProgID as the file type.
+        if (SUCCEEDED(hr) && szDefaultVal[0] != L'\0')
+        {
+            pszFileType = szDefaultVal;
+        }
+    }
+
+    // Create the key HKCR\<File Type>\shellex\ContextMenuHandlers\{friendlyName>}
+    hr = StringCchPrintf(szSubkey, ARRAYSIZE(szSubkey),
+        L"%s\\shellex\\ContextMenuHandlers\\%s", pszFileType, pszFriendlyName);
+    if (SUCCEEDED(hr))
+    {
+        // Set the default value of the key.
+        hr = SetHKCRRegistryKeyAndValue(szSubkey, NULL, szCLSID);
+    }
+
+    return hr;
 }
 
 HRESULT OCContextMenuRegHandler::UnregisterShellExtContextMenuHandler(
-       PCWSTR pszFileType, PCWSTR pszFriendlyName)
+    PCWSTR pszFileType, PCWSTR pszFriendlyName)
 {
-       if (pszFileType == NULL)
-       {
-               return E_INVALIDARG;
-       }
-
-       HRESULT hr;
-       
-       wchar_t szSubkey[MAX_PATH];
-
-       // If pszFileType starts with '.', try to read the default value of the 
-       // HKCR\<File Type> key which contains the ProgID to which the file type 
-       // is linked.
-       if (*pszFileType == L'.')
-       {
-               wchar_t szDefaultVal[260];
-               hr = GetHKCRRegistryKeyAndValue(pszFileType, NULL, szDefaultVal,
-                       sizeof(szDefaultVal));
-
-               // If the key exists and its default value is not empty, use the 
-               // ProgID as the file type.
-               if (SUCCEEDED(hr) && szDefaultVal[0] != L'\0')
-               {
-                       pszFileType = szDefaultVal;
-               }
-       }
-
-       // Remove the HKCR\<File Type>\shellex\ContextMenuHandlers\{friendlyName} key.
-       hr = StringCchPrintf(szSubkey, ARRAYSIZE(szSubkey),
-               L"%s\\shellex\\ContextMenuHandlers\\%s", pszFileType, pszFriendlyName);
-       if (SUCCEEDED(hr))
-       {
-               hr = HRESULT_FROM_WIN32(RegDelnode(HKEY_CLASSES_ROOT, szSubkey));
-       }
-
-       return hr;
+    if (pszFileType == NULL)
+    {
+        return E_INVALIDARG;
+    }
+
+    HRESULT hr;
+    
+    wchar_t szSubkey[MAX_PATH];
+
+    // If pszFileType starts with '.', try to read the default value of the 
+    // HKCR\<File Type> key which contains the ProgID to which the file type 
+    // is linked.
+    if (*pszFileType == L'.')
+    {
+        wchar_t szDefaultVal[260];
+        hr = GetHKCRRegistryKeyAndValue(pszFileType, NULL, szDefaultVal,
+            sizeof(szDefaultVal));
+
+        // If the key exists and its default value is not empty, use the 
+        // ProgID as the file type.
+        if (SUCCEEDED(hr) && szDefaultVal[0] != L'\0')
+        {
+            pszFileType = szDefaultVal;
+        }
+    }
+
+    // Remove the HKCR\<File Type>\shellex\ContextMenuHandlers\{friendlyName} key.
+    hr = StringCchPrintf(szSubkey, ARRAYSIZE(szSubkey),
+        L"%s\\shellex\\ContextMenuHandlers\\%s", pszFileType, pszFriendlyName);
+    if (SUCCEEDED(hr))
+    {
+        hr = HRESULT_FROM_WIN32(RegDelnode(HKEY_CLASSES_ROOT, szSubkey));
+    }
+
+    return hr;
 }
\ No newline at end of file
index b73db2fa44f963d374d2d8ce013dc97ae2422c90..061ee545da819f73a9fc63fea82349c5565b95f5 100644 (file)
 class __declspec(dllexport) OCContextMenuRegHandler
 {
 public:
-       static HRESULT MakeRegistryEntries(const CLSID& clsid, PCWSTR fileType);
-       static HRESULT RegisterCOMObject(PCWSTR modulePath, PCWSTR friendlyName, const CLSID& clsid);
-       static HRESULT RemoveRegistryEntries(PCWSTR friendlyName);
-       static HRESULT UnregisterCOMObject(const CLSID& clsid);
+    static HRESULT MakeRegistryEntries(const CLSID& clsid, PCWSTR fileType);
+    static HRESULT RegisterCOMObject(PCWSTR modulePath, PCWSTR friendlyName, const CLSID& clsid);
+    static HRESULT RemoveRegistryEntries(PCWSTR friendlyName);
+    static HRESULT UnregisterCOMObject(const CLSID& clsid);
 
-       static HRESULT RegisterInprocServer(PCWSTR pszModule, const CLSID& clsid, PCWSTR pszFriendlyName, PCWSTR pszThreadModel);
-       static HRESULT UnregisterInprocServer(const CLSID& clsid);
+    static HRESULT RegisterInprocServer(PCWSTR pszModule, const CLSID& clsid, PCWSTR pszFriendlyName, PCWSTR pszThreadModel);
+    static HRESULT UnregisterInprocServer(const CLSID& clsid);
 
-       static HRESULT RegisterShellExtContextMenuHandler(PCWSTR pszFileType, const CLSID& clsid, PCWSTR pszFriendlyName);
-       static HRESULT UnregisterShellExtContextMenuHandler(PCWSTR pszFileType, PCWSTR pszFriendlyName);
+    static HRESULT RegisterShellExtContextMenuHandler(PCWSTR pszFileType, const CLSID& clsid, PCWSTR pszFriendlyName);
+    static HRESULT UnregisterShellExtContextMenuHandler(PCWSTR pszFileType, PCWSTR pszFriendlyName);
 };
 
 #endif //OCCONTEXTMENUREGHANDLER_H
\ No newline at end of file
index 6e6b092cdccef5f9e48b9c40ca91c7eb33fc0b8f..e0ebc2e4aefd62f5ca4609d01542a3817ce9033e 100644 (file)
@@ -23,142 +23,142 @@ long dllReferenceCount = 0;
 
 BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
 {
-       switch (dwReason)
-       {
-               case DLL_PROCESS_ATTACH:
-                       instanceHandle = hModule;
-                       DisableThreadLibraryCalls(hModule);
-                       break;
-               case DLL_THREAD_ATTACH:
-               case DLL_THREAD_DETACH:
-               case DLL_PROCESS_DETACH:
-                       break;
-       }
-
-       return TRUE;
+    switch (dwReason)
+    {
+        case DLL_PROCESS_ATTACH:
+            instanceHandle = hModule;
+            DisableThreadLibraryCalls(hModule);
+            break;
+        case DLL_THREAD_ATTACH:
+        case DLL_THREAD_DETACH:
+        case DLL_PROCESS_DETACH:
+            break;
+    }
+
+    return TRUE;
 }
 
 HRESULT CreateFactory(REFIID riid, void **ppv, int state)
 {
-       HRESULT hResult = E_OUTOFMEMORY;
+    HRESULT hResult = E_OUTOFMEMORY;
 
-       OCOverlayFactory* ocOverlayFactory = new OCOverlayFactory(state);
+    OCOverlayFactory* ocOverlayFactory = new OCOverlayFactory(state);
 
-       if (ocOverlayFactory) {
-               hResult = ocOverlayFactory->QueryInterface(riid, ppv);
-               ocOverlayFactory->Release();
-       }
-       return hResult;
+    if (ocOverlayFactory) {
+        hResult = ocOverlayFactory->QueryInterface(riid, ppv);
+        ocOverlayFactory->Release();
+    }
+    return hResult;
 }
 
 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **ppv)
 {
     HRESULT hResult = CLASS_E_CLASSNOTAVAILABLE;
-       GUID guid;
+    GUID guid;
  
-       hResult = CLSIDFromString(OVERLAY_GUID_ERROR, (LPCLSID)&guid);
-       if (!SUCCEEDED(hResult)) { return hResult; }
-       if (IsEqualCLSID(guid, rclsid)) { return CreateFactory(riid, ppv, State_Error); }
+    hResult = CLSIDFromString(OVERLAY_GUID_ERROR, (LPCLSID)&guid);
+    if (!SUCCEEDED(hResult)) { return hResult; }
+    if (IsEqualCLSID(guid, rclsid)) { return CreateFactory(riid, ppv, State_Error); }
 
-       hResult = CLSIDFromString(OVERLAY_GUID_OK, (LPCLSID)&guid);
-       if (!SUCCEEDED(hResult)) { return hResult; }
-       if (IsEqualCLSID(guid, rclsid)) { return CreateFactory(riid, ppv, State_OK); }
+    hResult = CLSIDFromString(OVERLAY_GUID_OK, (LPCLSID)&guid);
+    if (!SUCCEEDED(hResult)) { return hResult; }
+    if (IsEqualCLSID(guid, rclsid)) { return CreateFactory(riid, ppv, State_OK); }
 
-       hResult = CLSIDFromString(OVERLAY_GUID_OK_SHARED, (LPCLSID)&guid);
-       if (!SUCCEEDED(hResult)) { return hResult; }
-       if (IsEqualCLSID(guid, rclsid)) { return CreateFactory(riid, ppv, State_OKShared); }
+    hResult = CLSIDFromString(OVERLAY_GUID_OK_SHARED, (LPCLSID)&guid);
+    if (!SUCCEEDED(hResult)) { return hResult; }
+    if (IsEqualCLSID(guid, rclsid)) { return CreateFactory(riid, ppv, State_OKShared); }
 
-       hResult = CLSIDFromString(OVERLAY_GUID_SYNC, (LPCLSID)&guid);
-       if (!SUCCEEDED(hResult)) { return hResult; }
-       if (IsEqualCLSID(guid, rclsid)) { return CreateFactory(riid, ppv, State_Sync); }
+    hResult = CLSIDFromString(OVERLAY_GUID_SYNC, (LPCLSID)&guid);
+    if (!SUCCEEDED(hResult)) { return hResult; }
+    if (IsEqualCLSID(guid, rclsid)) { return CreateFactory(riid, ppv, State_Sync); }
 
-       hResult = CLSIDFromString(OVERLAY_GUID_WARNING, (LPCLSID)&guid);
-       if (!SUCCEEDED(hResult)) { return hResult; }
-       if (IsEqualCLSID(guid, rclsid)) { return CreateFactory(riid, ppv, State_Warning); }
+    hResult = CLSIDFromString(OVERLAY_GUID_WARNING, (LPCLSID)&guid);
+    if (!SUCCEEDED(hResult)) { return hResult; }
+    if (IsEqualCLSID(guid, rclsid)) { return CreateFactory(riid, ppv, State_Warning); }
 
-       return CLASS_E_CLASSNOTAVAILABLE;
+    return CLASS_E_CLASSNOTAVAILABLE;
 }
 
 STDAPI DllCanUnloadNow(void)
 {
     return dllReferenceCount > 0 ? S_FALSE : S_OK;
-       
-       return S_FALSE;
+    
+    return S_FALSE;
 }
 
 HRESULT RegisterCLSID(LPCOLESTR guidStr, PCWSTR overlayStr, PCWSTR szModule)
 {
-       HRESULT hResult = S_OK;
+    HRESULT hResult = S_OK;
 
-       GUID guid;
-       hResult = CLSIDFromString(guidStr, (LPCLSID)&guid);
+    GUID guid;
+    hResult = CLSIDFromString(guidStr, (LPCLSID)&guid);
 
-       if (hResult != S_OK) {
-               return hResult;
-       }
+    if (hResult != S_OK) {
+        return hResult;
+    }
 
-       hResult = OCOverlayRegistrationHandler::RegisterCOMObject(szModule, OVERLAY_GENERIC_NAME, guid);
+    hResult = OCOverlayRegistrationHandler::RegisterCOMObject(szModule, OVERLAY_GENERIC_NAME, guid);
 
-       if (!SUCCEEDED(hResult)) {
-               return hResult;
-       }
+    if (!SUCCEEDED(hResult)) {
+        return hResult;
+    }
 
-       hResult = OCOverlayRegistrationHandler::MakeRegistryEntries(guid, overlayStr);
+    hResult = OCOverlayRegistrationHandler::MakeRegistryEntries(guid, overlayStr);
 
-       return hResult;
+    return hResult;
 }
 
 HRESULT UnregisterCLSID(LPCOLESTR guidStr, PCWSTR overlayStr)
 {
-       HRESULT hResult = S_OK;
-       GUID guid;
+    HRESULT hResult = S_OK;
+    GUID guid;
 
-       hResult = CLSIDFromString(guidStr, (LPCLSID)&guid);
+    hResult = CLSIDFromString(guidStr, (LPCLSID)&guid);
 
-       if (hResult != S_OK) {
-               return hResult;
-       }
+    if (hResult != S_OK) {
+        return hResult;
+    }
 
-       hResult = OCOverlayRegistrationHandler::UnregisterCOMObject(guid);
+    hResult = OCOverlayRegistrationHandler::UnregisterCOMObject(guid);
 
-       if (!SUCCEEDED(hResult)) {
-               return hResult;
-       }
+    if (!SUCCEEDED(hResult)) {
+        return hResult;
+    }
 
-       hResult = OCOverlayRegistrationHandler::RemoveRegistryEntries(overlayStr);
+    hResult = OCOverlayRegistrationHandler::RemoveRegistryEntries(overlayStr);
 
-       return hResult;
+    return hResult;
 }
 
 HRESULT _stdcall DllRegisterServer(void)
 {
-       HRESULT hResult = S_OK;
-
-       wchar_t szModule[MAX_PATH];
-
-       if (GetModuleFileName(instanceHandle, szModule, ARRAYSIZE(szModule)) == 0) {
-               hResult = HRESULT_FROM_WIN32(GetLastError());
-               return hResult;
-       }
-
-       // Unregister any obsolete CLSID when we register here
-       // Those CLSID were removed in 2.1, but we need to make sure to prevent any previous version
-       // of the extension on the system from loading at the same time as a new version to avoid crashing explorer.
-       UnregisterCLSID(OVERLAY_GUID_ERROR_SHARED, OVERLAY_NAME_ERROR_SHARED);
-       UnregisterCLSID(OVERLAY_GUID_SYNC_SHARED, OVERLAY_NAME_SYNC_SHARED);
-       UnregisterCLSID(OVERLAY_GUID_WARNING_SHARED, OVERLAY_NAME_WARNING_SHARED);
-
-       hResult = RegisterCLSID(OVERLAY_GUID_ERROR, OVERLAY_NAME_ERROR, szModule);
-       if (!SUCCEEDED(hResult)) { return hResult; }
-       hResult = RegisterCLSID(OVERLAY_GUID_OK, OVERLAY_NAME_OK, szModule);
-       if (!SUCCEEDED(hResult)) { return hResult; }
-       hResult = RegisterCLSID(OVERLAY_GUID_OK_SHARED, OVERLAY_NAME_OK_SHARED, szModule);
-       if (!SUCCEEDED(hResult)) { return hResult; }
-       hResult = RegisterCLSID(OVERLAY_GUID_SYNC, OVERLAY_NAME_SYNC, szModule);
-       if (!SUCCEEDED(hResult)) { return hResult; }
-       hResult = RegisterCLSID(OVERLAY_GUID_WARNING, OVERLAY_NAME_WARNING, szModule);
-
-       return hResult;
+    HRESULT hResult = S_OK;
+
+    wchar_t szModule[MAX_PATH];
+
+    if (GetModuleFileName(instanceHandle, szModule, ARRAYSIZE(szModule)) == 0) {
+        hResult = HRESULT_FROM_WIN32(GetLastError());
+        return hResult;
+    }
+
+    // Unregister any obsolete CLSID when we register here
+    // Those CLSID were removed in 2.1, but we need to make sure to prevent any previous version
+    // of the extension on the system from loading at the same time as a new version to avoid crashing explorer.
+    UnregisterCLSID(OVERLAY_GUID_ERROR_SHARED, OVERLAY_NAME_ERROR_SHARED);
+    UnregisterCLSID(OVERLAY_GUID_SYNC_SHARED, OVERLAY_NAME_SYNC_SHARED);
+    UnregisterCLSID(OVERLAY_GUID_WARNING_SHARED, OVERLAY_NAME_WARNING_SHARED);
+
+    hResult = RegisterCLSID(OVERLAY_GUID_ERROR, OVERLAY_NAME_ERROR, szModule);
+    if (!SUCCEEDED(hResult)) { return hResult; }
+    hResult = RegisterCLSID(OVERLAY_GUID_OK, OVERLAY_NAME_OK, szModule);
+    if (!SUCCEEDED(hResult)) { return hResult; }
+    hResult = RegisterCLSID(OVERLAY_GUID_OK_SHARED, OVERLAY_NAME_OK_SHARED, szModule);
+    if (!SUCCEEDED(hResult)) { return hResult; }
+    hResult = RegisterCLSID(OVERLAY_GUID_SYNC, OVERLAY_NAME_SYNC, szModule);
+    if (!SUCCEEDED(hResult)) { return hResult; }
+    hResult = RegisterCLSID(OVERLAY_GUID_WARNING, OVERLAY_NAME_WARNING, szModule);
+
+    return hResult;
 }
 
 STDAPI DllUnregisterServer(void)
@@ -167,21 +167,21 @@ STDAPI DllUnregisterServer(void)
 
     wchar_t szModule[MAX_PATH];
     
-       if (GetModuleFileNameW(instanceHandle, szModule, ARRAYSIZE(szModule)) == 0)
+    if (GetModuleFileNameW(instanceHandle, szModule, ARRAYSIZE(szModule)) == 0)
     {
         hResult = HRESULT_FROM_WIN32(GetLastError());
         return hResult;
     }
 
-       hResult = UnregisterCLSID(OVERLAY_GUID_ERROR, OVERLAY_NAME_ERROR);
-       if (!SUCCEEDED(hResult)) { return hResult; }
-       hResult = UnregisterCLSID(OVERLAY_GUID_OK, OVERLAY_NAME_OK);
-       if (!SUCCEEDED(hResult)) { return hResult; }
-       hResult = UnregisterCLSID(OVERLAY_GUID_OK_SHARED, OVERLAY_NAME_OK_SHARED);
-       if (!SUCCEEDED(hResult)) { return hResult; }
-       hResult = UnregisterCLSID(OVERLAY_GUID_SYNC, OVERLAY_NAME_SYNC);
-       if (!SUCCEEDED(hResult)) { return hResult; }
-       hResult = UnregisterCLSID(OVERLAY_GUID_WARNING, OVERLAY_NAME_WARNING);
+    hResult = UnregisterCLSID(OVERLAY_GUID_ERROR, OVERLAY_NAME_ERROR);
+    if (!SUCCEEDED(hResult)) { return hResult; }
+    hResult = UnregisterCLSID(OVERLAY_GUID_OK, OVERLAY_NAME_OK);
+    if (!SUCCEEDED(hResult)) { return hResult; }
+    hResult = UnregisterCLSID(OVERLAY_GUID_OK_SHARED, OVERLAY_NAME_OK_SHARED);
+    if (!SUCCEEDED(hResult)) { return hResult; }
+    hResult = UnregisterCLSID(OVERLAY_GUID_SYNC, OVERLAY_NAME_SYNC);
+    if (!SUCCEEDED(hResult)) { return hResult; }
+    hResult = UnregisterCLSID(OVERLAY_GUID_WARNING, OVERLAY_NAME_WARNING);
 
     return hResult;
 }
index a5b6938fcd1b9f96af6bec7095b5db25cd0219f2..1a07205bf5ef0d36252a4206dfbb44f5ec02c039 100644 (file)
@@ -45,19 +45,19 @@ unique_ptr<RemotePathChecker> s_instance;
 
 RemotePathChecker *getGlobalChecker()
 {
-       // On Vista we'll run into issue #2680 if we try to create the thread+pipe connection
-       // on any DllGetClassObject of our registered classes.
-       // Work around the issue by creating the static RemotePathChecker only once actually needed.
-       static once_flag s_onceFlag;
-       call_once(s_onceFlag, [] { s_instance.reset(new RemotePathChecker); });
+    // On Vista we'll run into issue #2680 if we try to create the thread+pipe connection
+    // on any DllGetClassObject of our registered classes.
+    // Work around the issue by creating the static RemotePathChecker only once actually needed.
+    static once_flag s_onceFlag;
+    call_once(s_onceFlag, [] { s_instance.reset(new RemotePathChecker); });
 
-       return s_instance.get();
+    return s_instance.get();
 }
 
 }
 OCOverlay::OCOverlay(int state) 
-       : _referenceCount(1)
-       , _state(state)
+    : _referenceCount(1)
+    , _state(state)
 {
 }
 
@@ -89,7 +89,7 @@ IFACEMETHODIMP OCOverlay::QueryInterface(REFIID riid, void **ppv)
     {
         AddRef();
     }
-       
+
     return hr;
 }
 
@@ -106,80 +106,80 @@ IFACEMETHODIMP_(ULONG) OCOverlay::Release()
 
 IFACEMETHODIMP OCOverlay::GetPriority(int *pPriority)
 {
-       // this defines which handler has prededence, so
-       // we order this in terms of likelyhood
-       switch (_state) {
-       case State_OK:
-               *pPriority = 0; break;
-       case State_OKShared:
-               *pPriority = 1; break;
-       case State_Warning:
-               *pPriority = 2; break;
-       case State_Sync:
-               *pPriority = 3; break;
-       case State_Error:
-               *pPriority = 4; break;
-       default:
-               *pPriority = 5; break;
-       }
-
-       return S_OK;
+    // this defines which handler has prededence, so
+    // we order this in terms of likelyhood
+    switch (_state) {
+    case State_OK:
+        *pPriority = 0; break;
+    case State_OKShared:
+        *pPriority = 1; break;
+    case State_Warning:
+        *pPriority = 2; break;
+    case State_Sync:
+        *pPriority = 3; break;
+    case State_Error:
+        *pPriority = 4; break;
+    default:
+        *pPriority = 5; break;
+    }
+
+    return S_OK;
 }
 
  IFACEMETHODIMP OCOverlay::IsMemberOf(PCWSTR pwszPath, DWORD dwAttrib)
 {
-       RemotePathChecker* checker = getGlobalChecker();
-       auto watchedDirectories = checker->WatchedDirectories();
-
-       wstring wpath(pwszPath);
-       wpath.append(L"\\");
-       vector<wstring>::iterator it;
-       bool watched = false;
-       for (it = watchedDirectories.begin(); it != watchedDirectories.end(); ++it) {
-               if (StringUtil::begins_with(wpath, *it)) {
-                       watched = true;
-               }
-       }
-
-       if (!watched) {
-               return MAKE_HRESULT(S_FALSE, 0, 0);
-       }
-
-       int state = 0;
-       if (!checker->IsMonitoredPath(pwszPath, &state)) {
-               return MAKE_HRESULT(S_FALSE, 0, 0);
-       }
-       return MAKE_HRESULT(state == _state ? S_OK : S_FALSE, 0, 0);
+    RemotePathChecker* checker = getGlobalChecker();
+    auto watchedDirectories = checker->WatchedDirectories();
+
+    wstring wpath(pwszPath);
+    wpath.append(L"\\");
+    vector<wstring>::iterator it;
+    bool watched = false;
+    for (it = watchedDirectories.begin(); it != watchedDirectories.end(); ++it) {
+        if (StringUtil::begins_with(wpath, *it)) {
+            watched = true;
+        }
+    }
+
+    if (!watched) {
+        return MAKE_HRESULT(S_FALSE, 0, 0);
+    }
+
+    int state = 0;
+    if (!checker->IsMonitoredPath(pwszPath, &state)) {
+        return MAKE_HRESULT(S_FALSE, 0, 0);
+    }
+    return MAKE_HRESULT(state == _state ? S_OK : S_FALSE, 0, 0);
 }
 
 IFACEMETHODIMP OCOverlay::GetOverlayInfo(PWSTR pwszIconFile, int cchMax, int *pIndex, DWORD *pdwFlags)
 {
-       *pIndex = 0;
-       *pdwFlags = ISIOI_ICONFILE | ISIOI_ICONINDEX;
-       *pIndex = _state;
-
-       if (GetModuleFileName(instanceHandle, pwszIconFile, cchMax) == 0) {     
-               HRESULT hResult = HRESULT_FROM_WIN32(GetLastError());
-               wcerr << L"IsOK? " << (hResult == S_OK) << L" with path " << pwszIconFile << L", index " << *pIndex << endl;
-               return hResult;
-       }
+    *pIndex = 0;
+    *pdwFlags = ISIOI_ICONFILE | ISIOI_ICONINDEX;
+    *pIndex = _state;
+
+    if (GetModuleFileName(instanceHandle, pwszIconFile, cchMax) == 0) {
+        HRESULT hResult = HRESULT_FROM_WIN32(GetLastError());
+        wcerr << L"IsOK? " << (hResult == S_OK) << L" with path " << pwszIconFile << L", index " << *pIndex << endl;
+        return hResult;
+    }
 
-       return S_OK;
+    return S_OK;
 }
 
 
 bool OCOverlay::_IsOverlaysEnabled()
 {
-       //int enable;
-       bool success = false;
-       
-       //if(RegistryUtil::ReadRegistry(REGISTRY_ROOT_KEY, REGISTRY_ENABLE_OVERLAY, &enable))
-       //{
-       //      if(enable) {
-       //              success = true;
-       //      }
-       //}
-
-       return success;
+    //int enable;
+    bool success = false;
+
+    //if(RegistryUtil::ReadRegistry(REGISTRY_ROOT_KEY, REGISTRY_ENABLE_OVERLAY, &enable))
+    //{
+    //  if(enable) {
+    //      success = true;
+    //  }
+    //}
+
+    return success;
 }
 
index 39d2cb90d67f27f394097edcbe9bf30617e15560..fc8bc4104a04c19efee240dba496e6aaa57d7482 100644 (file)
@@ -21,22 +21,22 @@ class OCOverlay : public IShellIconOverlayIdentifier
 
 {
 public:
-       OCOverlay(int state);
+    OCOverlay(int state);
 
-       IFACEMETHODIMP_(ULONG) AddRef();
-       IFACEMETHODIMP GetOverlayInfo(PWSTR pwszIconFile, int cchMax, int *pIndex, DWORD *pdwFlags);
-       IFACEMETHODIMP GetPriority(int *pPriority);
-       IFACEMETHODIMP IsMemberOf(PCWSTR pwszPath, DWORD dwAttrib);
-       IFACEMETHODIMP QueryInterface(REFIID riid, void **ppv);
+    IFACEMETHODIMP_(ULONG) AddRef();
+    IFACEMETHODIMP GetOverlayInfo(PWSTR pwszIconFile, int cchMax, int *pIndex, DWORD *pdwFlags);
+    IFACEMETHODIMP GetPriority(int *pPriority);
+    IFACEMETHODIMP IsMemberOf(PCWSTR pwszPath, DWORD dwAttrib);
+    IFACEMETHODIMP QueryInterface(REFIID riid, void **ppv);
     IFACEMETHODIMP_(ULONG) Release();
 
 protected:
     ~OCOverlay();
 
 private:
-       bool _IsOverlaysEnabled();
+    bool _IsOverlaysEnabled();
     long _referenceCount;
-       int _state;
+    int _state;
 };
 
 #endif
\ No newline at end of file
index ce7a824bcfbe72c7b1aac7948773c0cd832175ff..1a317dae144e885780860dcbd165f27d84fb2e3e 100644 (file)
@@ -20,7 +20,7 @@
 extern long dllReferenceCount;
 
 OCOverlayFactory::OCOverlayFactory(int state)
-       : _referenceCount(1), _state(state)
+    : _referenceCount(1), _state(state)
 {
     InterlockedIncrement(&dllReferenceCount);
 }
@@ -32,7 +32,7 @@ OCOverlayFactory::~OCOverlayFactory()
 
 IFACEMETHODIMP OCOverlayFactory::QueryInterface(REFIID riid, void **ppv)
 {
-       HRESULT hResult = S_OK;
+    HRESULT hResult = S_OK;
 
     if (IsEqualIID(IID_IUnknown, riid) || 
         IsEqualIID(IID_IClassFactory, riid))
@@ -66,20 +66,20 @@ IFACEMETHODIMP_(ULONG) OCOverlayFactory::Release()
 }
 
 IFACEMETHODIMP OCOverlayFactory::CreateInstance(
-       IUnknown *pUnkOuter, REFIID riid, void **ppv)
+    IUnknown *pUnkOuter, REFIID riid, void **ppv)
 {
-       HRESULT hResult = CLASS_E_NOAGGREGATION;
+    HRESULT hResult = CLASS_E_NOAGGREGATION;
 
     if (pUnkOuter != NULL) { return hResult; }
 
-       hResult = E_OUTOFMEMORY;
+    hResult = E_OUTOFMEMORY;
     OCOverlay *lrOverlay = new (std::nothrow) OCOverlay(_state);
-       if (!lrOverlay) { return hResult; }
+    if (!lrOverlay) { return hResult; }
 
     hResult = lrOverlay->QueryInterface(riid, ppv);
-       lrOverlay->Release();
+    lrOverlay->Release();
 
-       return hResult;
+    return hResult;
 }
 
 IFACEMETHODIMP OCOverlayFactory::LockServer(BOOL fLock)
index d1a6d1dbec625d5070bb2232e1e6b8493c7bd9f9..364baa2c7cbea1843fa1478862db3984669581ec 100644 (file)
 #pragma once
 
 enum State {
-       State_Error = 0,
-       State_OK, State_OKShared,
-       State_Sync, 
-       State_Warning
+    State_Error = 0,
+    State_OK, State_OKShared,
+    State_Sync, 
+    State_Warning
 };
 
 class OCOverlayFactory : public IClassFactory
 {
 public:
-       OCOverlayFactory(int state);
+    OCOverlayFactory(int state);
 
-       IFACEMETHODIMP_(ULONG) AddRef();
+    IFACEMETHODIMP_(ULONG) AddRef();
     IFACEMETHODIMP CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppv);
-       IFACEMETHODIMP LockServer(BOOL fLock);
+    IFACEMETHODIMP LockServer(BOOL fLock);
     IFACEMETHODIMP QueryInterface(REFIID riid, void **ppv);
     IFACEMETHODIMP_(ULONG) Release();
 
@@ -40,7 +40,7 @@ protected:
 
 private:
     long _referenceCount;
-       int _state;
+    int _state;
 };
 
 #endif
\ No newline at end of file
index c8f51897e74fa417b74882f3c81da1492f89dc8a..0ef83b84c5f3170cff4bb3bbf7086e883aea57d9 100644 (file)
@@ -23,52 +23,52 @@ using namespace std;
 
 HRESULT OCOverlayRegistrationHandler::MakeRegistryEntries(const CLSID& clsid, PCWSTR friendlyName)
 {
-       HRESULT hResult;
-       HKEY shellOverlayKey = NULL;
-       // the key may not exist yet
-       hResult = HRESULT_FROM_WIN32(RegCreateKeyEx(HKEY_LOCAL_MACHINE, REGISTRY_OVERLAY_KEY, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &shellOverlayKey, NULL));
-       if (!SUCCEEDED(hResult)) {
-               hResult = RegCreateKey(HKEY_LOCAL_MACHINE, REGISTRY_OVERLAY_KEY, &shellOverlayKey);
-               if(!SUCCEEDED(hResult)) {
-                       return hResult;
-               }
-       }
-
-       HKEY syncExOverlayKey = NULL;
-       hResult = HRESULT_FROM_WIN32(RegCreateKeyEx(shellOverlayKey, friendlyName, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &syncExOverlayKey, NULL));
-
-       if (!SUCCEEDED(hResult)) {
-               return hResult;
-       }
-
-       wchar_t stringCLSID[MAX_PATH];
+    HRESULT hResult;
+    HKEY shellOverlayKey = NULL;
+    // the key may not exist yet
+    hResult = HRESULT_FROM_WIN32(RegCreateKeyEx(HKEY_LOCAL_MACHINE, REGISTRY_OVERLAY_KEY, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &shellOverlayKey, NULL));
+    if (!SUCCEEDED(hResult)) {
+        hResult = RegCreateKey(HKEY_LOCAL_MACHINE, REGISTRY_OVERLAY_KEY, &shellOverlayKey);
+        if(!SUCCEEDED(hResult)) {
+            return hResult;
+        }
+    }
+
+    HKEY syncExOverlayKey = NULL;
+    hResult = HRESULT_FROM_WIN32(RegCreateKeyEx(shellOverlayKey, friendlyName, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &syncExOverlayKey, NULL));
+
+    if (!SUCCEEDED(hResult)) {
+        return hResult;
+    }
+
+    wchar_t stringCLSID[MAX_PATH];
     StringFromGUID2(clsid, stringCLSID, ARRAYSIZE(stringCLSID));
-       LPCTSTR value = stringCLSID;
-       hResult = RegSetValueEx(syncExOverlayKey, NULL, 0, REG_SZ, (LPBYTE)value, (DWORD)((wcslen(value)+1) * sizeof(TCHAR)));
-       if (!SUCCEEDED(hResult)) {
-               return hResult;
-       }
+    LPCTSTR value = stringCLSID;
+    hResult = RegSetValueEx(syncExOverlayKey, NULL, 0, REG_SZ, (LPBYTE)value, (DWORD)((wcslen(value)+1) * sizeof(TCHAR)));
+    if (!SUCCEEDED(hResult)) {
+        return hResult;
+    }
 
-       return hResult;
+    return hResult;
 }
 
 HRESULT OCOverlayRegistrationHandler::RemoveRegistryEntries(PCWSTR friendlyName)
 {
-       HRESULT hResult;
-       HKEY shellOverlayKey = NULL;
-       hResult = HRESULT_FROM_WIN32(RegOpenKeyEx(HKEY_LOCAL_MACHINE, REGISTRY_OVERLAY_KEY, 0, KEY_WRITE, &shellOverlayKey));
+    HRESULT hResult;
+    HKEY shellOverlayKey = NULL;
+    hResult = HRESULT_FROM_WIN32(RegOpenKeyEx(HKEY_LOCAL_MACHINE, REGISTRY_OVERLAY_KEY, 0, KEY_WRITE, &shellOverlayKey));
 
-       if (!SUCCEEDED(hResult)) {
-               return hResult;
-       }
+    if (!SUCCEEDED(hResult)) {
+        return hResult;
+    }
 
-       HKEY syncExOverlayKey = NULL;
-       hResult = HRESULT_FROM_WIN32(RegDeleteKey(shellOverlayKey, friendlyName));
-       if (!SUCCEEDED(hResult)) {
-               return hResult;
-       }
+    HKEY syncExOverlayKey = NULL;
+    hResult = HRESULT_FROM_WIN32(RegDeleteKey(shellOverlayKey, friendlyName));
+    if (!SUCCEEDED(hResult)) {
+        return hResult;
+    }
 
-       return hResult;
+    return hResult;
 }
 
 HRESULT OCOverlayRegistrationHandler::RegisterCOMObject(PCWSTR modulePath, PCWSTR friendlyName, const CLSID& clsid)
@@ -79,45 +79,45 @@ HRESULT OCOverlayRegistrationHandler::RegisterCOMObject(PCWSTR modulePath, PCWST
 
     wchar_t stringCLSID[MAX_PATH];
     StringFromGUID2(clsid, stringCLSID, ARRAYSIZE(stringCLSID));
-       HRESULT hResult;
-       HKEY hKey = NULL;
+    HRESULT hResult;
+    HKEY hKey = NULL;
 
-       hResult = HRESULT_FROM_WIN32(RegOpenKeyEx(HKEY_CLASSES_ROOT, REGISTRY_CLSID, 0, KEY_WRITE, &hKey));
-       if (!SUCCEEDED(hResult)) {
-               return hResult;
-       }
+    hResult = HRESULT_FROM_WIN32(RegOpenKeyEx(HKEY_CLASSES_ROOT, REGISTRY_CLSID, 0, KEY_WRITE, &hKey));
+    if (!SUCCEEDED(hResult)) {
+        return hResult;
+    }
 
-       HKEY clsidKey = NULL;
-       hResult = HRESULT_FROM_WIN32(RegCreateKeyEx(hKey, stringCLSID, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &clsidKey, NULL));
-       if(!SUCCEEDED(hResult)) {
-               return hResult;
-       }
+    HKEY clsidKey = NULL;
+    hResult = HRESULT_FROM_WIN32(RegCreateKeyEx(hKey, stringCLSID, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &clsidKey, NULL));
+    if(!SUCCEEDED(hResult)) {
+        return hResult;
+    }
 
-       hResult = HRESULT_FROM_WIN32(RegSetValue(clsidKey, NULL, REG_SZ, friendlyName, (DWORD) wcslen(friendlyName)));
+    hResult = HRESULT_FROM_WIN32(RegSetValue(clsidKey, NULL, REG_SZ, friendlyName, (DWORD) wcslen(friendlyName)));
 
-       HKEY inprocessKey = NULL;
-       hResult = HRESULT_FROM_WIN32(RegCreateKeyEx(clsidKey, REGISTRY_IN_PROCESS, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &inprocessKey, NULL));
-       if(!SUCCEEDED(hResult)) {
-               return hResult;
-       }
+    HKEY inprocessKey = NULL;
+    hResult = HRESULT_FROM_WIN32(RegCreateKeyEx(clsidKey, REGISTRY_IN_PROCESS, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &inprocessKey, NULL));
+    if(!SUCCEEDED(hResult)) {
+        return hResult;
+    }
 
-       hResult = HRESULT_FROM_WIN32(RegSetValue(inprocessKey, NULL, REG_SZ, modulePath, (DWORD) wcslen(modulePath)));
+    hResult = HRESULT_FROM_WIN32(RegSetValue(inprocessKey, NULL, REG_SZ, modulePath, (DWORD) wcslen(modulePath)));
 
-       if(!SUCCEEDED(hResult)) {
-               return hResult;
-       }
+    if(!SUCCEEDED(hResult)) {
+        return hResult;
+    }
 
     hResult = HRESULT_FROM_WIN32(RegSetValueEx(inprocessKey, REGISTRY_THREADING, 0, REG_SZ, (LPBYTE)REGISTRY_APARTMENT, (DWORD)((wcslen(REGISTRY_APARTMENT)+1) * sizeof(TCHAR))));
-       if(!SUCCEEDED(hResult)) {
-               return hResult;
-       }
+    if(!SUCCEEDED(hResult)) {
+        return hResult;
+    }
 
-       hResult = HRESULT_FROM_WIN32(RegSetValueEx(inprocessKey, REGISTRY_VERSION, 0, REG_SZ, (LPBYTE)REGISTRY_VERSION_NUMBER, (DWORD)(wcslen(REGISTRY_VERSION_NUMBER)+1) * sizeof(TCHAR)));
-       if(!SUCCEEDED(hResult)) {
-               return hResult;
-       }
+    hResult = HRESULT_FROM_WIN32(RegSetValueEx(inprocessKey, REGISTRY_VERSION, 0, REG_SZ, (LPBYTE)REGISTRY_VERSION_NUMBER, (DWORD)(wcslen(REGISTRY_VERSION_NUMBER)+1) * sizeof(TCHAR)));
+    if(!SUCCEEDED(hResult)) {
+        return hResult;
+    }
 
-       return S_OK;
+    return S_OK;
 }
 
 HRESULT OCOverlayRegistrationHandler::UnregisterCOMObject(const CLSID& clsid)
@@ -125,28 +125,28 @@ HRESULT OCOverlayRegistrationHandler::UnregisterCOMObject(const CLSID& clsid)
     wchar_t stringCLSID[MAX_PATH];
 
     StringFromGUID2(clsid, stringCLSID, ARRAYSIZE(stringCLSID));
-       HRESULT hResult;
-       HKEY hKey = NULL;
-       hResult = HRESULT_FROM_WIN32(RegOpenKeyEx(HKEY_CLASSES_ROOT, REGISTRY_CLSID, 0, DELETE, &hKey));
-       if (!SUCCEEDED(hResult)) {
-               return hResult;
-       }
-
-       HKEY clsidKey = NULL;
-       hResult = HRESULT_FROM_WIN32(RegOpenKeyEx(hKey, stringCLSID, 0, DELETE, &clsidKey));
-       if(!SUCCEEDED(hResult)) {
-               return hResult;
-       }
-
-       hResult = HRESULT_FROM_WIN32(RegDeleteKey(clsidKey, REGISTRY_IN_PROCESS));
-       if(!SUCCEEDED(hResult)) {
-               return hResult;
-       }
-
-       hResult = HRESULT_FROM_WIN32(RegDeleteKey(hKey, stringCLSID));
-       if(!SUCCEEDED(hResult)) {
-               return hResult;
-       }
-
-       return S_OK;
+    HRESULT hResult;
+    HKEY hKey = NULL;
+    hResult = HRESULT_FROM_WIN32(RegOpenKeyEx(HKEY_CLASSES_ROOT, REGISTRY_CLSID, 0, DELETE, &hKey));
+    if (!SUCCEEDED(hResult)) {
+        return hResult;
+    }
+
+    HKEY clsidKey = NULL;
+    hResult = HRESULT_FROM_WIN32(RegOpenKeyEx(hKey, stringCLSID, 0, DELETE, &clsidKey));
+    if(!SUCCEEDED(hResult)) {
+        return hResult;
+    }
+
+    hResult = HRESULT_FROM_WIN32(RegDeleteKey(clsidKey, REGISTRY_IN_PROCESS));
+    if(!SUCCEEDED(hResult)) {
+        return hResult;
+    }
+
+    hResult = HRESULT_FROM_WIN32(RegDeleteKey(hKey, stringCLSID));
+    if(!SUCCEEDED(hResult)) {
+        return hResult;
+    }
+
+    return S_OK;
 }
\ No newline at end of file
index 5a475cbdf324ea718f2d6a82186c046f3e35cfe4..098ac6921113d81564f2ded8569932e2b1423404 100644 (file)
 
 class __declspec(dllexport) OCOverlayRegistrationHandler 
 {
-       public:
-               static HRESULT MakeRegistryEntries(const CLSID& clsid, PCWSTR fileType);
-               static HRESULT RegisterCOMObject(PCWSTR modulePath, PCWSTR friendlyName, const CLSID& clsid);
-               static HRESULT RemoveRegistryEntries(PCWSTR friendlyName);
-               static HRESULT UnregisterCOMObject(const CLSID& clsid);
+    public:
+        static HRESULT MakeRegistryEntries(const CLSID& clsid, PCWSTR fileType);
+        static HRESULT RegisterCOMObject(PCWSTR modulePath, PCWSTR friendlyName, const CLSID& clsid);
+        static HRESULT RemoveRegistryEntries(PCWSTR friendlyName);
+        static HRESULT UnregisterCOMObject(const CLSID& clsid);
 };
 
 #endif
\ No newline at end of file
index 5adf0a523911493903a4918f86f1a6ce8d5250a8..5e35d749c303a6af50ca4bfd46eadafdbcfe8276 100644 (file)
 */
 
 
-#define OVERLAY_GUID_ERROR                     L"{0960F090-F328-48A3-B746-276B1E3C3722}"
-#define OVERLAY_GUID_ERROR_SHARED      L"{0960F091-F328-48A3-B746-276B1E3C3722}"
-#define OVERLAY_GUID_OK                                L"{0960F092-F328-48A3-B746-276B1E3C3722}"
-#define OVERLAY_GUID_OK_SHARED         L"{0960F093-F328-48A3-B746-276B1E3C3722}"
-#define OVERLAY_GUID_SYNC                      L"{0960F094-F328-48A3-B746-276B1E3C3722}"
-#define OVERLAY_GUID_SYNC_SHARED       L"{0960F095-F328-48A3-B746-276B1E3C3722}"
-#define OVERLAY_GUID_WARNING           L"{0960F096-F328-48A3-B746-276B1E3C3722}"
+#define OVERLAY_GUID_ERROR          L"{0960F090-F328-48A3-B746-276B1E3C3722}"
+#define OVERLAY_GUID_ERROR_SHARED   L"{0960F091-F328-48A3-B746-276B1E3C3722}"
+#define OVERLAY_GUID_OK             L"{0960F092-F328-48A3-B746-276B1E3C3722}"
+#define OVERLAY_GUID_OK_SHARED      L"{0960F093-F328-48A3-B746-276B1E3C3722}"
+#define OVERLAY_GUID_SYNC           L"{0960F094-F328-48A3-B746-276B1E3C3722}"
+#define OVERLAY_GUID_SYNC_SHARED    L"{0960F095-F328-48A3-B746-276B1E3C3722}"
+#define OVERLAY_GUID_WARNING        L"{0960F096-F328-48A3-B746-276B1E3C3722}"
 #define OVERLAY_GUID_WARNING_SHARED L"{0960F097-F328-48A3-B746-276B1E3C3722}"
 
 #define OVERLAY_GENERIC_NAME        L"OC Overlay Handler"
 
 // two spaces to put us ahead of the competition :/
-#define OVERLAY_NAME_ERROR                     L"  OCError"
-#define OVERLAY_NAME_ERROR_SHARED      L"  OCErrorShared"
-#define OVERLAY_NAME_OK                                L"  OCOK"
-#define OVERLAY_NAME_OK_SHARED         L"  OCOKShared"
-#define OVERLAY_NAME_SYNC                      L"  OCSync"
-#define OVERLAY_NAME_SYNC_SHARED       L"  OCSyncShared"
-#define OVERLAY_NAME_WARNING           L"  OCWarning"
-#define OVERLAY_NAME_WARNING_SHARED    L"  OCWarningShared"
-
-#define REGISTRY_OVERLAY_KEY           L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ShellIconOverlayIdentifiers"
-#define REGISTRY_CLSID                         L"CLSID"
-#define REGISTRY_IN_PROCESS                    L"InprocServer32"
-#define REGISTRY_THREADING                     L"ThreadingModel"
-#define REGISTRY_APARTMENT                     L"Apartment"
-#define REGISTRY_VERSION                       L"Version"
-#define REGISTRY_VERSION_NUMBER                L"1.0"
+#define OVERLAY_NAME_ERROR          L"  OCError"
+#define OVERLAY_NAME_ERROR_SHARED   L"  OCErrorShared"
+#define OVERLAY_NAME_OK             L"  OCOK"
+#define OVERLAY_NAME_OK_SHARED      L"  OCOKShared"
+#define OVERLAY_NAME_SYNC           L"  OCSync"
+#define OVERLAY_NAME_SYNC_SHARED    L"  OCSyncShared"
+#define OVERLAY_NAME_WARNING        L"  OCWarning"
+#define OVERLAY_NAME_WARNING_SHARED L"  OCWarningShared"
+
+#define REGISTRY_OVERLAY_KEY        L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ShellIconOverlayIdentifiers"
+#define REGISTRY_CLSID              L"CLSID"
+#define REGISTRY_IN_PROCESS         L"InprocServer32"
+#define REGISTRY_THREADING          L"ThreadingModel"
+#define REGISTRY_APARTMENT          L"Apartment"
+#define REGISTRY_VERSION            L"Version"
+#define REGISTRY_VERSION_NUMBER     L"1.0"
 
 //Registry values for running
-#define REGISTRY_ENABLE_OVERLAY                L"EnableOverlay"
+#define REGISTRY_ENABLE_OVERLAY     L"EnableOverlay"
 
-#define GET_FILE_OVERLAY_ID            L"getFileIconId"
+#define GET_FILE_OVERLAY_ID     L"getFileIconId"
 
-#define PORT                           34001
\ No newline at end of file
+#define PORT                34001
\ No newline at end of file
index 5b419f7050be9efa46ffdf1480dcb496e6307e21..b7dd64c32cd4a82ce29abf300979bbe64b51929a 100644 (file)
@@ -31,23 +31,23 @@ using namespace std;
 namespace {
 
 std::wstring getUserName() {
-       DWORD  len = DEFAULT_BUFLEN;
-       TCHAR  buf[DEFAULT_BUFLEN];
-       if (GetUserName(buf, &len)) {
-               return std::wstring(&buf[0], len);
-       } else {
-               return std::wstring();
-       }
+    DWORD  len = DEFAULT_BUFLEN;
+    TCHAR  buf[DEFAULT_BUFLEN];
+    if (GetUserName(buf, &len)) {
+        return std::wstring(&buf[0], len);
+    } else {
+        return std::wstring();
+    }
 }
 
 }
 
 std::wstring CommunicationSocket::DefaultPipePath()
 {
-       auto pipename = std::wstring(L"\\\\.\\pipe\\");
-       pipename += L"ownCloud-";
-       pipename += getUserName();
-       return pipename;
+    auto pipename = std::wstring(L"\\\\.\\pipe\\");
+    pipename += L"ownCloud-";
+    pipename += getUserName();
+    return pipename;
 }
 
 CommunicationSocket::CommunicationSocket()
@@ -57,23 +57,23 @@ CommunicationSocket::CommunicationSocket()
 
 CommunicationSocket::~CommunicationSocket()
 {
-       Close();
+    Close();
 }
 
 bool CommunicationSocket::Close()
 {
-       if (_pipe == INVALID_HANDLE_VALUE) {
-               return false;
-       }
-       CloseHandle(_pipe);
-       _pipe = INVALID_HANDLE_VALUE;
-       return true;
+    if (_pipe == INVALID_HANDLE_VALUE) {
+        return false;
+    }
+    CloseHandle(_pipe);
+    _pipe = INVALID_HANDLE_VALUE;
+    return true;
 }
 
 
 bool CommunicationSocket::Connect(const std::wstring &pipename)
 {
-       _pipe = CreateFile(pipename.data(), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
+    _pipe = CreateFile(pipename.data(), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
 
     if (_pipe == INVALID_HANDLE_VALUE) {
         return false;
@@ -84,7 +84,7 @@ bool CommunicationSocket::Connect(const std::wstring &pipename)
 
 bool CommunicationSocket::SendMsg(const wchar_t* message) const
 {
-       auto utf8_msg = StringUtil::toUtf8(message);
+    auto utf8_msg = StringUtil::toUtf8(message);
 
     DWORD numBytesWritten = 0;
     auto result = WriteFile( _pipe, utf8_msg.c_str(), DWORD(utf8_msg.size()), &numBytesWritten, NULL);
@@ -92,7 +92,7 @@ bool CommunicationSocket::SendMsg(const wchar_t* message) const
     if (result) {
         return true;
     } else {
-               const_cast<CommunicationSocket*>(this)->Close();
+        const_cast<CommunicationSocket*>(this)->Close();
 
         return false;
     }
@@ -100,9 +100,9 @@ bool CommunicationSocket::SendMsg(const wchar_t* message) const
 
 bool CommunicationSocket::ReadLine(wstring* response)
 {
-       if (!response) {
-               return false;
-       }
+    if (!response) {
+        return false;
+    }
 
     response->clear();
 
@@ -110,7 +110,7 @@ bool CommunicationSocket::ReadLine(wstring* response)
         return false;
     }
 
-       while (true) {
+    while (true) {
         int lbPos = 0;
         auto it = std::find(_buffer.begin() + lbPos, _buffer.end(), '\n');
         if (it != _buffer.end()) {
@@ -121,24 +121,24 @@ bool CommunicationSocket::ReadLine(wstring* response)
 
         std::array<char, 128> resp_utf8;
         DWORD numBytesRead = 0;
-               DWORD totalBytesAvailable = 0;
+        DWORD totalBytesAvailable = 0;
 
-               if (!PeekNamedPipe(_pipe, NULL, 0, 0, &totalBytesAvailable, 0)) {
-                       Close();
-                       return false;
-               }
-               if (totalBytesAvailable == 0) {
-                       return false;
-               }
+        if (!PeekNamedPipe(_pipe, NULL, 0, 0, &totalBytesAvailable, 0)) {
+            Close();
+            return false;
+        }
+        if (totalBytesAvailable == 0) {
+            return false;
+        }
 
-               if (!ReadFile(_pipe, resp_utf8.data(), DWORD(resp_utf8.size()), &numBytesRead, NULL)) {
+        if (!ReadFile(_pipe, resp_utf8.data(), DWORD(resp_utf8.size()), &numBytesRead, NULL)) {
             Close();
             return false;
         }
         if (numBytesRead <= 0) {
             return false;
         }
-               _buffer.insert(_buffer.end(), resp_utf8.begin(), resp_utf8.begin()+numBytesRead);
+        _buffer.insert(_buffer.end(), resp_utf8.begin(), resp_utf8.begin()+numBytesRead);
         continue;
-       }
+    }
 }
index fc06f066886a3f68f22264f7832a78bc8e830c8c..68414ef988cc27e729759419108f053506953b93 100644 (file)
 class __declspec(dllexport) CommunicationSocket
 {
 public:
-       static std::wstring DefaultPipePath();
+    static std::wstring DefaultPipePath();
 
-       CommunicationSocket();
-       ~CommunicationSocket();
+    CommunicationSocket();
+    ~CommunicationSocket();
 
-       bool Connect(const std::wstring& pipename);
-       bool Close();
+    bool Connect(const std::wstring& pipename);
+    bool Close();
 
-       bool SendMsg(const wchar_t*) const;
-       bool ReadLine(std::wstring*);
+    bool SendMsg(const wchar_t*) const;
+    bool ReadLine(std::wstring*);
 
     HANDLE Event() { return _pipe; }
 
-private:       
-       HANDLE _pipe;
-       std::vector<char> _buffer;
+private:    
+    HANDLE _pipe;
+    std::vector<char> _buffer;
     bool _connected;
 };
 
index 2ebf7f4a47f101c76ceaf42ed39c3cf8f6649446..a0d381c9236589c07220424968935dd35428040e 100644 (file)
@@ -22,65 +22,65 @@ using namespace std;
 
 bool FileUtil::IsChildFile(const wchar_t* rootFolder, vector<wstring>* files)
 {
-       for(vector<wstring>::iterator it = files->begin(); it != files->end(); it++)
-       {
-               wstring file = *it;
+    for(vector<wstring>::iterator it = files->begin(); it != files->end(); it++)
+    {
+        wstring file = *it;
 
-               size_t found = file.find(rootFolder);
+        size_t found = file.find(rootFolder);
 
-               if(found != string::npos)
-               {
-                       return true;    
-               }
-       }
+        if(found != string::npos)
+        {
+            return true;    
+        }
+    }
 
-       return false;
+    return false;
 }
 
 bool FileUtil::IsChildFile(const wchar_t* rootFolder, const wchar_t* file)
 {
-       wstring* f = new wstring(file);
+    wstring* f = new wstring(file);
 
-       size_t found = f->find(rootFolder);
+    size_t found = f->find(rootFolder);
 
-       if(found != string::npos)
-       {
-               return true;    
-       }
-       
-       return false;
+    if(found != string::npos)
+    {
+        return true;    
+    }
+    
+    return false;
 }
 
 bool FileUtil::IsChildFileOfRoot(std::vector<std::wstring>* files) 
 {
-       wstring* rootFolder = new wstring();
-       bool needed = false;
+    wstring* rootFolder = new wstring();
+    bool needed = false;
 
-       if(RegistryUtil::ReadRegistry(REGISTRY_ROOT_KEY, REGISTRY_FILTER_FOLDER, rootFolder))
-       {
-               if(IsChildFile(rootFolder->c_str(), files))
-               {
-                       needed = true;
-               }
-       }
+    if(RegistryUtil::ReadRegistry(REGISTRY_ROOT_KEY, REGISTRY_FILTER_FOLDER, rootFolder))
+    {
+        if(IsChildFile(rootFolder->c_str(), files))
+        {
+            needed = true;
+        }
+    }
 
-       delete rootFolder;
-       return needed;
+    delete rootFolder;
+    return needed;
 }
 
 bool FileUtil::IsChildFileOfRoot(const wchar_t* filePath)
 {
-       wstring* rootFolder = new wstring();
-       bool needed = false;
-       
-       if(RegistryUtil::ReadRegistry(REGISTRY_ROOT_KEY, REGISTRY_FILTER_FOLDER, rootFolder))
-       {
-               if(FileUtil::IsChildFile(rootFolder->c_str(), filePath))
-               {
-                       needed = true;
-               }
-       }
+    wstring* rootFolder = new wstring();
+    bool needed = false;
+    
+    if(RegistryUtil::ReadRegistry(REGISTRY_ROOT_KEY, REGISTRY_FILTER_FOLDER, rootFolder))
+    {
+        if(FileUtil::IsChildFile(rootFolder->c_str(), filePath))
+        {
+            needed = true;
+        }
+    }
 
-       delete rootFolder;
-       return needed;
+    delete rootFolder;
+    return needed;
 }
\ No newline at end of file
index 650bc471f6f9542a4f348ce040e76155dfa19758..35a5be08938d8c9e010e2175cfa186baae5dcf32 100644 (file)
 class __declspec(dllexport) FileUtil
 {
 public:
-       FileUtil();
+    FileUtil();
 
-       ~FileUtil();
+    ~FileUtil();
 
-       static bool IsChildFile(const wchar_t*, std::vector<std::wstring>*);
-       static bool IsChildFile(const wchar_t*, const wchar_t*);
-       static bool IsChildFileOfRoot(std::vector<std::wstring>*);
-       static bool IsChildFileOfRoot(const wchar_t*);
+    static bool IsChildFile(const wchar_t*, std::vector<std::wstring>*);
+    static bool IsChildFile(const wchar_t*, const wchar_t*);
+    static bool IsChildFileOfRoot(std::vector<std::wstring>*);
+    static bool IsChildFileOfRoot(const wchar_t*);
 
-private:       
+private:    
 };
 
 #endif
\ No newline at end of file
index b86005f718374749bb79a48b56a5d2c463a8cbf4..31da93180d9a7b7a72c8f4fc4dcd60125b07fede 100644 (file)
@@ -25,8 +25,8 @@ using namespace std;
 
 OCMessage::OCMessage(void)
 {
-       _command = new wstring();
-       _value = new wstring();
+    _command = new wstring();
+    _value = new wstring();
 }
 
 OCMessage::~OCMessage(void)
@@ -35,40 +35,40 @@ OCMessage::~OCMessage(void)
 
 bool OCMessage::InitFromMessage(const wstring* message)
 {
-       if(message->length() == 0)
-       {
-               return false;
-       }
-       
-       if(!ParserUtil::GetItem(COMMAND, message, _command))
-       {
-               return false;
-       }
+    if(message->length() == 0)
+    {
+        return false;
+    }
+    
+    if(!ParserUtil::GetItem(COMMAND, message, _command))
+    {
+        return false;
+    }
 
-       if(!ParserUtil::GetItem(VALUE, message, _value))
-       {
-               return false;
-       }
+    if(!ParserUtil::GetItem(VALUE, message, _value))
+    {
+        return false;
+    }
 
-       return true;
+    return true;
 }
-       
+    
 std::wstring* OCMessage::GetCommand()
 {
-       return _command;
+    return _command;
 }
 
 std::wstring* OCMessage::GetValue()
 {
-       return _value;
+    return _value;
 }
 
 void OCMessage::SetCommand(std::wstring* command)
 {
-       _command = command;
+    _command = command;
 }
 
 void OCMessage::SetValue(std::wstring* value)
 {
-       _value = value;
+    _value = value;
 }
index 131f3d714391a7e511a718deec924ba09e9f9762..7b0eefca3b25dd5214fe48c96783b38664edaaa7 100644 (file)
@@ -23,20 +23,20 @@ class __declspec(dllexport) OCMessage
 {
 public:
     OCMessage(void);
-       ~OCMessage(void);
+    ~OCMessage(void);
 
-       bool InitFromMessage(const std::wstring*);
+    bool InitFromMessage(const std::wstring*);
 
-       std::wstring* GetCommand();
-       std::wstring* GetValue();
+    std::wstring* GetCommand();
+    std::wstring* GetValue();
 
-       void SetCommand(std::wstring*);
-       void SetValue(std::wstring*);
+    void SetCommand(std::wstring*);
+    void SetValue(std::wstring*);
 
 private:
 
     std::wstring* _command;
-       std::wstring* _value;
+    std::wstring* _value;
 };
 
 #endif
\ No newline at end of file
index ba7d9f1018c3fe20422fa7cd14eba7be539bafc7..5ca05f6701baf5cb1b4770e6e51f40285ae5e2a8 100644 (file)
@@ -21,369 +21,369 @@ using namespace std;
 
 bool ParserUtil::GetItem(const wchar_t* item, const wstring* message, wstring* result)
 {
-       size_t start = message->find(item, 0);
-
-       if(start == string::npos)
-       {
-               return false;
-       }
-
-       size_t end = message->find(COLON, start);
-
-       if(end == string::npos)
-       {
-               return false;
-       }
-
-       //Move to next character after :
-       end += 1;
-
-       wchar_t c = message->at(end);
-
-       //Move to the next character, which is the start of the value
-       end += 1;
-       
-       if(c == '[')
-       {
-               return GetList(end - 1, message, result);
-       }
-       else
-       {
-               return GetValue(end, message, result);
-       }
+    size_t start = message->find(item, 0);
+
+    if(start == string::npos)
+    {
+        return false;
+    }
+
+    size_t end = message->find(COLON, start);
+
+    if(end == string::npos)
+    {
+        return false;
+    }
+
+    //Move to next character after :
+    end += 1;
+
+    wchar_t c = message->at(end);
+
+    //Move to the next character, which is the start of the value
+    end += 1;
+    
+    if(c == '[')
+    {
+        return GetList(end - 1, message, result);
+    }
+    else
+    {
+        return GetValue(end, message, result);
+    }
 }
 
 bool ParserUtil::GetList(size_t start, const wstring* message, wstring* result)
 {
-       size_t end = start + 1;
-
-       int openBraceCount = 1;
-
-       while(openBraceCount > 0)
-       {
-               size_t closeBraceLocation = message->find(CLOSE_BRACE, end);
-               size_t openBraceLocation = message->find(OPEN_BRACE, end);
-
-               if(closeBraceLocation < openBraceLocation)
-               {
-                       openBraceCount--;
-                       end = closeBraceLocation + 1;
-               }
-               else if(openBraceLocation < closeBraceLocation)
-               {
-                       openBraceCount++;
-                       end = openBraceLocation + 1;
-               }
-
-       }
-       
-       size_t length = end - start;
-
-       return GetString(start, end, message, result);
+    size_t end = start + 1;
+
+    int openBraceCount = 1;
+
+    while(openBraceCount > 0)
+    {
+        size_t closeBraceLocation = message->find(CLOSE_BRACE, end);
+        size_t openBraceLocation = message->find(OPEN_BRACE, end);
+
+        if(closeBraceLocation < openBraceLocation)
+        {
+            openBraceCount--;
+            end = closeBraceLocation + 1;
+        }
+        else if(openBraceLocation < closeBraceLocation)
+        {
+            openBraceCount++;
+            end = openBraceLocation + 1;
+        }
+
+    }
+    
+    size_t length = end - start;
+
+    return GetString(start, end, message, result);
 }
 
 size_t ParserUtil::GetNextStringItemInList(const wstring* message, size_t start, wstring* result)
 {
-       size_t end = string::npos;
-       size_t commaLocation = message->find(COMMA, start);
-
-       if(commaLocation == string::npos)
-       {
-               end = message->find(CLOSE_BRACE, start);
-               if(end == string::npos)
-               {
-                       end = message->length();
-               }
-               else
-               {
-                       end = end - 1;
-               }
-       }
-       else
-       {
-               end = commaLocation - 1;
-       }
-
-       if(!GetString(start + 2, end, message, result))
-       {
-               return string::npos;
-       }
-
-       return end + 2;
+    size_t end = string::npos;
+    size_t commaLocation = message->find(COMMA, start);
+
+    if(commaLocation == string::npos)
+    {
+        end = message->find(CLOSE_BRACE, start);
+        if(end == string::npos)
+        {
+            end = message->length();
+        }
+        else
+        {
+            end = end - 1;
+        }
+    }
+    else
+    {
+        end = commaLocation - 1;
+    }
+
+    if(!GetString(start + 2, end, message, result))
+    {
+        return string::npos;
+    }
+
+    return end + 2;
 }
 
 size_t ParserUtil::GetNextOCItemInList(const wstring* message, size_t start, wstring* result)
 {
-       size_t end = message->find(OPEN_CURLY_BRACE, start) + 1;
-
-       int openBraceCount = 1;
-
-       while(openBraceCount > 0)
-       {
-               size_t closeBraceLocation = message->find(CLOSE_CURLY_BRACE, end);
-               size_t openBraceLocation = message->find(OPEN_CURLY_BRACE, end);
-
-               if(closeBraceLocation < openBraceLocation)
-               {
-                       openBraceCount--;
-                       end = closeBraceLocation + 1;
-               }
-               else if(openBraceLocation < closeBraceLocation)
-               {
-                       openBraceCount++;
-                       end = openBraceLocation + 1;
-               }
-       }
-
-       size_t length = end - start;
-
-       if(!GetString(start, end, message, result))
-       {
-               return string::npos;
-       }
-
-       return end;
+    size_t end = message->find(OPEN_CURLY_BRACE, start) + 1;
+
+    int openBraceCount = 1;
+
+    while(openBraceCount > 0)
+    {
+        size_t closeBraceLocation = message->find(CLOSE_CURLY_BRACE, end);
+        size_t openBraceLocation = message->find(OPEN_CURLY_BRACE, end);
+
+        if(closeBraceLocation < openBraceLocation)
+        {
+            openBraceCount--;
+            end = closeBraceLocation + 1;
+        }
+        else if(openBraceLocation < closeBraceLocation)
+        {
+            openBraceCount++;
+            end = openBraceLocation + 1;
+        }
+    }
+
+    size_t length = end - start;
+
+    if(!GetString(start, end, message, result))
+    {
+        return string::npos;
+    }
+
+    return end;
 }
 
 bool ParserUtil::GetValue(size_t start, const wstring* message, wstring* result)
 {
-       if(message->at(start - 1) == '\"')
-       {
-               size_t end = message->find(QUOTE, start);
-               return GetString(start, end, message, result);
-       }
-       else
-       {
-               start = start - 1;
-
-               size_t end = message->find(COMMA, start);
-               
-               result->append(message->substr(start, end-start));
-       }
-
-       return true;
+    if(message->at(start - 1) == '\"')
+    {
+        size_t end = message->find(QUOTE, start);
+        return GetString(start, end, message, result);
+    }
+    else
+    {
+        start = start - 1;
+
+        size_t end = message->find(COMMA, start);
+        
+        result->append(message->substr(start, end-start));
+    }
+
+    return true;
 }
 
 bool ParserUtil::GetString(size_t start, size_t end, const wstring* message, wstring* result)
 {
-       if(end == string::npos)
-       {
-               return false;
-       }
-
-       size_t length = end - start;
-
-       if(length > 0)
-       {
-               result->append(message->substr(start, length));
-       }
-       else
-       {
-               result->append(L"");
-       }
-
-       
-       return true;
+    if(end == string::npos)
+    {
+        return false;
+    }
+
+    size_t length = end - start;
+
+    if(length > 0)
+    {
+        result->append(message->substr(start, length));
+    }
+    else
+    {
+        result->append(L"");
+    }
+
+    
+    return true;
 }
 
 bool ParserUtil::IsList(wstring* message)
 {
-       wchar_t c = message->at(0);
-       
-       if(c == '[')
-       {
-               return true;
-       }
-
-       return false;
+    wchar_t c = message->at(0);
+    
+    if(c == '[')
+    {
+        return true;
+    }
+
+    return false;
 }
 
 bool ParserUtil::ParseJsonList(wstring* message, vector<wstring*>* items)
 {
 
-       size_t currentLocation = message->find(OPEN_BRACE, 0);
+    size_t currentLocation = message->find(OPEN_BRACE, 0);
 
-       while(currentLocation < message->size())
-       {
-               wstring* item = new wstring();
+    while(currentLocation < message->size())
+    {
+        wstring* item = new wstring();
 
-               currentLocation = ParserUtil::GetNextStringItemInList(message, currentLocation, item);
+        currentLocation = ParserUtil::GetNextStringItemInList(message, currentLocation, item);
 
-               if(currentLocation == string::npos)
-               {
-                       return false;
-               }
+        if(currentLocation == string::npos)
+        {
+            return false;
+        }
 
-               items->push_back(item);
-       }
+        items->push_back(item);
+    }
 
-       return true;
+    return true;
 }
 
 bool ParserUtil::ParseOCList(wstring* message, vector<wstring*>* items)
 {
 
-       size_t currentLocation = message->find(OPEN_CURLY_BRACE, 0);
+    size_t currentLocation = message->find(OPEN_CURLY_BRACE, 0);
 
-       while(currentLocation < message->size())
-       {
-               wstring* item = new wstring();
+    while(currentLocation < message->size())
+    {
+        wstring* item = new wstring();
 
-               currentLocation = ParserUtil::GetNextOCItemInList(message, currentLocation, item);
+        currentLocation = ParserUtil::GetNextOCItemInList(message, currentLocation, item);
 
-               if(currentLocation == string::npos)
-               {
-                       return false;
-               }
+        if(currentLocation == string::npos)
+        {
+            return false;
+        }
 
-               items->push_back(item);
-       }
+        items->push_back(item);
+    }
 
-       return true;
+    return true;
 }
 
 bool ParserUtil::ParseOCMessageList(wstring* message, vector<OCMessage*>* messages)
 {
-       vector<wstring*>* items = new vector<wstring*>();
+    vector<wstring*>* items = new vector<wstring*>();
 
-       if(!ParseOCList(message, items))
-       {
-               return false;
-       }
+    if(!ParseOCList(message, items))
+    {
+        return false;
+    }
 
-       for(vector<wstring*>::iterator it = items->begin(); it != items->end(); it++)
-       {
-               wstring* temp = *it;
+    for(vector<wstring*>::iterator it = items->begin(); it != items->end(); it++)
+    {
+        wstring* temp = *it;
 
-               OCMessage* message = new OCMessage();
-               message->InitFromMessage(temp);
+        OCMessage* message = new OCMessage();
+        message->InitFromMessage(temp);
 
-               messages->push_back(message);
-       }
+        messages->push_back(message);
+    }
 
-       return true;
+    return true;
 }
 
 bool ParserUtil::SerializeList(std::vector<std::wstring>* list, std::wstring* result, bool escapeQuotes)
 {
-       if(result == 0)
-       {
-               return false;
-       }
+    if(result == 0)
+    {
+        return false;
+    }
 
-       result->append(OPEN_BRACE);
+    result->append(OPEN_BRACE);
 
-       for(vector<wstring>::iterator it = list->begin(); it != list->end(); it++)
-       {
-               wstring value = *it;
+    for(vector<wstring>::iterator it = list->begin(); it != list->end(); it++)
+    {
+        wstring value = *it;
 
-               if(escapeQuotes)
-               {
-                       result->append(BACK_SLASH);
-               }
+        if(escapeQuotes)
+        {
+            result->append(BACK_SLASH);
+        }
 
-               result->append(QUOTE);
-               result->append(value.c_str());
+        result->append(QUOTE);
+        result->append(value.c_str());
 
-               if(escapeQuotes)
-               {
-                       result->append(BACK_SLASH);
-               }
+        if(escapeQuotes)
+        {
+            result->append(BACK_SLASH);
+        }
 
-               result->append(QUOTE);
-               result->append(COMMA);
-       }
+        result->append(QUOTE);
+        result->append(COMMA);
+    }
 
-       //Erase last comma
-       result->erase(result->size() - 1, 1);
+    //Erase last comma
+    result->erase(result->size() - 1, 1);
 
-       result->append(CLOSE_BRACE);
+    result->append(CLOSE_BRACE);
 
-       return true;
+    return true;
 }
 
 bool ParserUtil::SerializeMessage(std::map<std::wstring*, std::wstring*>* arguments, std::wstring* result, bool escapeQuotes)
 {
-       if(result == 0)
-       {
-               return false;
-       }
+    if(result == 0)
+    {
+        return false;
+    }
 
-       result->append(OPEN_CURLY_BRACE);
+    result->append(OPEN_CURLY_BRACE);
 
-       for(map<wstring*, wstring*>::iterator it = arguments->begin(); it != arguments->end(); it++)
-       {
-               wstring key = *it->first;
-               wstring value = *it->second;
+    for(map<wstring*, wstring*>::iterator it = arguments->begin(); it != arguments->end(); it++)
+    {
+        wstring key = *it->first;
+        wstring value = *it->second;
 
-               if(escapeQuotes)
-               {
-                       result->append(BACK_SLASH);
-               }
+        if(escapeQuotes)
+        {
+            result->append(BACK_SLASH);
+        }
 
-               result->append(QUOTE);
-               result->append(key.c_str());
+        result->append(QUOTE);
+        result->append(key.c_str());
 
-               if(escapeQuotes)
-               {
-                       result->append(BACK_SLASH);
-               }
+        if(escapeQuotes)
+        {
+            result->append(BACK_SLASH);
+        }
 
-               result->append(QUOTE);
-               result->append(COLON);
-               result->append(value.c_str());
-               result->append(COMMA);
-       }
+        result->append(QUOTE);
+        result->append(COLON);
+        result->append(value.c_str());
+        result->append(COMMA);
+    }
 
-       //Erase last comma
-       result->erase(result->size() - 1, 1);
+    //Erase last comma
+    result->erase(result->size() - 1, 1);
 
-       result->append(CLOSE_CURLY_BRACE);
+    result->append(CLOSE_CURLY_BRACE);
 
-       return true;
+    return true;
 }
 
 bool ParserUtil::SerializeMessage(OCMessage* OCMessage, std::wstring* result)
 {
-       if(result == 0)
-       {
-               return false;
-       }
-
-       result->append(OPEN_CURLY_BRACE);
-
-       result->append(QUOTE);
-       result->append(COMMAND);
-       result->append(QUOTE);
-
-       result->append(COLON);
-
-       result->append(QUOTE);
-       result->append(OCMessage->GetCommand()->c_str());
-       result->append(QUOTE);
-
-       result->append(COMMA);
-       
-       result->append(QUOTE);
-       result->append(VALUE);
-       result->append(QUOTE);
-
-       result->append(COLON);
-       
-       if(!IsList(OCMessage->GetValue()))
-       {
-               result->append(QUOTE);
-       }
-       
-       result->append(OCMessage->GetValue()->c_str());
-       
-       if(!IsList(OCMessage->GetValue()))
-       {
-               result->append(QUOTE);
-       }
-
-       result->append(CLOSE_CURLY_BRACE);
-
-       return true;
+    if(result == 0)
+    {
+        return false;
+    }
+
+    result->append(OPEN_CURLY_BRACE);
+
+    result->append(QUOTE);
+    result->append(COMMAND);
+    result->append(QUOTE);
+
+    result->append(COLON);
+
+    result->append(QUOTE);
+    result->append(OCMessage->GetCommand()->c_str());
+    result->append(QUOTE);
+
+    result->append(COMMA);
+    
+    result->append(QUOTE);
+    result->append(VALUE);
+    result->append(QUOTE);
+
+    result->append(COLON);
+    
+    if(!IsList(OCMessage->GetValue()))
+    {
+        result->append(QUOTE);
+    }
+    
+    result->append(OCMessage->GetValue()->c_str());
+    
+    if(!IsList(OCMessage->GetValue()))
+    {
+        result->append(QUOTE);
+    }
+
+    result->append(CLOSE_CURLY_BRACE);
+
+    return true;
 }
 
index 737a6724a0a8837a924170785c453dc14b62bd54..5542ac4d694b4d58c5a4b4a0d81287527129d65e 100644 (file)
@@ -22,49 +22,49 @@ using namespace std;
 
 bool RegistryUtil::ReadRegistry(const wchar_t* key, const wchar_t* name, int* result)
 {
-       wstring* strResult = new wstring();
+    wstring* strResult = new wstring();
 
-       if(!ReadRegistry(key, name, strResult))
-       {
-               return false;
-       }
+    if(!ReadRegistry(key, name, strResult))
+    {
+        return false;
+    }
 
-       *result = stoi( strResult->c_str() );
+    *result = stoi( strResult->c_str() );
 
-       return true;
+    return true;
 }
 
 bool RegistryUtil::ReadRegistry(const wchar_t* key, const wchar_t* name, wstring* result)
 {
-       HRESULT hResult;
+    HRESULT hResult;
 
-       HKEY rootKey = NULL;
+    HKEY rootKey = NULL;
 
-       hResult = HRESULT_FROM_WIN32(RegOpenKeyEx(HKEY_CURRENT_USER, (LPCWSTR)key, NULL, KEY_READ, &rootKey));
+    hResult = HRESULT_FROM_WIN32(RegOpenKeyEx(HKEY_CURRENT_USER, (LPCWSTR)key, NULL, KEY_READ, &rootKey));
 
-       if(!SUCCEEDED(hResult))
-       {
-               return false;
-       }
+    if(!SUCCEEDED(hResult))
+    {
+        return false;
+    }
 
-       wchar_t value[SIZE];
-       DWORD value_length = SIZE;
-       
+    wchar_t value[SIZE];
+    DWORD value_length = SIZE;
+    
     hResult = RegQueryValueEx(rootKey, (LPCWSTR)name, NULL, NULL, (LPBYTE)value, &value_length );
 
-       if(!SUCCEEDED(hResult))
-       {
-               return false;
-       }
+    if(!SUCCEEDED(hResult))
+    {
+        return false;
+    }
 
-       result->append(value);
+    result->append(value);
 
-       HRESULT hResult2 = RegCloseKey(rootKey);
+    HRESULT hResult2 = RegCloseKey(rootKey);
 
-       if (!SUCCEEDED(hResult2))
-       {
-               return false;
-       }
+    if (!SUCCEEDED(hResult2))
+    {
+        return false;
+    }
 
-       return true;
+    return true;
 }
index 1928d64ce77d7c9254881ff80f5257d106bc752b..9cc40a957232ef674f49c92caa6ad1bc46caede2 100644 (file)
 class __declspec(dllexport) RegistryUtil
 {
 public:
-       RegistryUtil();
+    RegistryUtil();
 
-       ~RegistryUtil();
+    ~RegistryUtil();
 
-       static bool ReadRegistry(const wchar_t*,  const wchar_t*, int*);
-       static bool ReadRegistry(const wchar_t*,  const wchar_t*, std::wstring*);
+    static bool ReadRegistry(const wchar_t*,  const wchar_t*, int*);
+    static bool ReadRegistry(const wchar_t*,  const wchar_t*, std::wstring*);
 };
 
 #endif
\ No newline at end of file
index d831182c8659380804158b07fe23c81fb3b7887c..52f91eb277e72e565d489700ad39120557b4ca60 100644 (file)
@@ -40,7 +40,7 @@ void RemotePathChecker::workerThreadLoop()
     std::unordered_set<std::wstring> asked;
 
     while(!_stop) {
-               Sleep(50);
+        Sleep(50);
 
         if (!connected) {
             asked.clear();
@@ -72,14 +72,14 @@ void RemotePathChecker::workerThreadLoop()
 
         std::wstring response;
         while (!_stop && socket.ReadLine(&response)) {
-                       if (StringUtil::begins_with(response, wstring(L"REGISTER_PATH:"))) {
-                               wstring responsePath = response.substr(14); // length of REGISTER_PATH:
-
-                               {   std::unique_lock<std::mutex> lock(_mutex);
-                                       _watchedDirectories.push_back(responsePath);
-                               }
-                               SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_PATH | SHCNF_FLUSHNOWAIT, responsePath.data(), NULL);
-                       } else if (StringUtil::begins_with(response, wstring(L"UNREGISTER_PATH:"))) {
+            if (StringUtil::begins_with(response, wstring(L"REGISTER_PATH:"))) {
+                wstring responsePath = response.substr(14); // length of REGISTER_PATH:
+
+                {   std::unique_lock<std::mutex> lock(_mutex);
+                    _watchedDirectories.push_back(responsePath);
+                }
+                SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_PATH | SHCNF_FLUSHNOWAIT, responsePath.data(), NULL);
+            } else if (StringUtil::begins_with(response, wstring(L"UNREGISTER_PATH:"))) {
                 wstring responsePath = response.substr(16); // length of UNREGISTER_PATH:
 
                 {   std::unique_lock<std::mutex> lock(_mutex);
@@ -98,7 +98,7 @@ void RemotePathChecker::workerThreadLoop()
                     // Assume that we won't need this at this point, UNREGISTER_PATH is rare
                     _oldCache.clear();
                 }
-                               SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_PATH | SHCNF_FLUSHNOWAIT, responsePath.data(), NULL);
+                SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_PATH | SHCNF_FLUSHNOWAIT, responsePath.data(), NULL);
             } else if (StringUtil::begins_with(response, wstring(L"STATUS:")) ||
                     StringUtil::begins_with(response, wstring(L"BROADCAST:"))) {
 
@@ -128,9 +128,9 @@ void RemotePathChecker::workerThreadLoop()
                 if (changed) {
                     SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_PATH | SHCNF_FLUSHNOWAIT, responsePath.data(), NULL);
                 }
-                       }
-                       else if (StringUtil::begins_with(response, wstring(L"UPDATE_VIEW"))) {
-                               std::unique_lock<std::mutex> lock(_mutex);
+            }
+            else if (StringUtil::begins_with(response, wstring(L"UPDATE_VIEW"))) {
+                std::unique_lock<std::mutex> lock(_mutex);
                 // Keep the old states to continue having something to display while the new state is
                 // requested from the client, triggered by clearing _cache.
                 _oldCache.insert(_cache.cbegin(), _cache.cend());
@@ -144,20 +144,20 @@ void RemotePathChecker::workerThreadLoop()
                     SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_PATH | SHCNF_FLUSHNOWAIT, it->first.data(), NULL);
                 }
             }
-               }
+        }
 
-               if (socket.Event() == INVALID_HANDLE_VALUE) {
-                       std::unique_lock<std::mutex> lock(_mutex);
-                       _cache.clear();
+        if (socket.Event() == INVALID_HANDLE_VALUE) {
+            std::unique_lock<std::mutex> lock(_mutex);
+            _cache.clear();
             _oldCache.clear();
-                       _watchedDirectories.clear();
-                       _connected = connected = false;
-               }
+            _watchedDirectories.clear();
+            _connected = connected = false;
+        }
 
-               if (_stop) return;
+        if (_stop) return;
 
-               HANDLE handles[2] = { _newQueries, socket.Event() };
-               WaitForMultipleObjects(2, handles, false, 0);
+        HANDLE handles[2] = { _newQueries, socket.Event() };
+        WaitForMultipleObjects(2, handles, false, 0);
     }
 }
 
@@ -166,7 +166,7 @@ void RemotePathChecker::workerThreadLoop()
 RemotePathChecker::RemotePathChecker()
     : _connected(false)
     , _newQueries(CreateEvent(NULL, true, true, NULL))
-       , _thread([this]{ this->workerThreadLoop(); })
+    , _thread([this]{ this->workerThreadLoop(); })
 {
 }
 
@@ -217,25 +217,25 @@ bool RemotePathChecker::IsMonitoredPath(const wchar_t* filePath, int* state)
 
 RemotePathChecker::FileState RemotePathChecker::_StrToFileState(const std::wstring &str)
 {
-       if (str == L"NOP" || str == L"NONE") {
-               return StateNone;
-       } else if (str == L"SYNC" || str == L"NEW") {
-               return StateSync;
-       } else if (str == L"SYNC+SWM" || str == L"NEW+SWM") {
-               return StateSync;
-       } else if (str == L"OK") {
-               return StateOk;
-       } else if (str == L"OK+SWM") {
-               return StateOkSWM;
-       } else if (str == L"IGNORE") {
-               return StateWarning;
-       } else if (str == L"IGNORE+SWM") {
-               return StateWarning;
-       } else if (str == L"ERROR") {
-               return StateError;
-       } else if (str == L"ERROR+SWM") {
-               return StateError;
-       }
-
-       return StateNone;
+    if (str == L"NOP" || str == L"NONE") {
+        return StateNone;
+    } else if (str == L"SYNC" || str == L"NEW") {
+        return StateSync;
+    } else if (str == L"SYNC+SWM" || str == L"NEW+SWM") {
+        return StateSync;
+    } else if (str == L"OK") {
+        return StateOk;
+    } else if (str == L"OK+SWM") {
+        return StateOkSWM;
+    } else if (str == L"IGNORE") {
+        return StateWarning;
+    } else if (str == L"IGNORE+SWM") {
+        return StateWarning;
+    } else if (str == L"ERROR") {
+        return StateError;
+    } else if (str == L"ERROR+SWM") {
+        return StateError;
+    }
+
+    return StateNone;
 }
index fdafafb755e514338353e410a1ccacbe77c89968..654d7f70f996630a29d142d788aa1d9efd10fb03 100644 (file)
 
 class __declspec(dllexport) RemotePathChecker {
 public:
-       enum FileState {
-               // Order synced with OCOverlay
-               StateError = 0,
-               StateOk, StateOkSWM,
-               StateSync,
-               StateWarning,
-               StateNone
-       };
-       RemotePathChecker();
+    enum FileState {
+        // Order synced with OCOverlay
+        StateError = 0,
+        StateOk, StateOkSWM,
+        StateSync,
+        StateWarning,
+        StateNone
+    };
+    RemotePathChecker();
     ~RemotePathChecker();
-       std::vector<std::wstring> WatchedDirectories();
-       bool IsMonitoredPath(const wchar_t* filePath, int* state);
+    std::vector<std::wstring> WatchedDirectories();
+    bool IsMonitoredPath(const wchar_t* filePath, int* state);
 
 private:
-       FileState _StrToFileState(const std::wstring &str);
+    FileState _StrToFileState(const std::wstring &str);
     std::mutex _mutex;
     std::atomic<bool> _stop;
 
@@ -61,7 +61,7 @@ private:
     //std::condition_variable _newQueries;
     HANDLE _newQueries;
 
-       std::thread _thread;
+    std::thread _thread;
     void workerThreadLoop();
 };
 
index 5fe8f4e88bcca36126d1d3315928c635649d890f..bd056ba683ea2ddf59a643d931733b291f8b2d51 100644 (file)
 
 std::string StringUtil::toUtf8(const wchar_t *utf16, int len)
 {
-       if (len < 0) {
-               len = (int) wcslen(utf16);
-       }
+    if (len < 0) {
+        len = (int) wcslen(utf16);
+    }
     std::wstring_convert<std::codecvt_utf8_utf16<wchar_t> > converter;
     return converter.to_bytes(utf16, utf16+len);
 }
 
 std::wstring StringUtil::toUtf16(const char *utf8, int len)
 {
-       if (len < 0) {
-               len = (int) strlen(utf8);
-       }
-       std::wstring_convert<std::codecvt_utf8_utf16<wchar_t> > converter;
+    if (len < 0) {
+        len = (int) strlen(utf8);
+    }
+    std::wstring_convert<std::codecvt_utf8_utf16<wchar_t> > converter;
     return converter.from_bytes(utf8, utf8+len);
 }
index 65d322fcc88bab7f8dd2031eaaaa11ac5d73df18..8614639ac4a4f8a4e5e2931b20ccd8f9e4c8dbd8 100644 (file)
 
 class __declspec(dllexport) StringUtil {
 public:
-       static std::string  toUtf8(const wchar_t* utf16, int len = -1);
-       static std::wstring toUtf16(const char* utf8, int len = -1);
+    static std::string  toUtf8(const wchar_t* utf16, int len = -1);
+    static std::wstring toUtf16(const char* utf8, int len = -1);
 
-       template<class T>
-       static bool begins_with(const T& input, const T& match)
-       {
-               return input.size() >= match.size()
-                       && std::equal(match.begin(), match.end(), input.begin());
-       }
+    template<class T>
+    static bool begins_with(const T& input, const T& match)
+    {
+        return input.size() >= match.size()
+            && std::equal(match.begin(), match.end(), input.begin());
+    }
 };
 
 #endif // STRINGUTIL_H