update for HEAD-2003091401
[reactos.git] / subsys / system / explorer / Seashell / SeaShellExt / ShellDetails.cpp
1 //*******************************************************************************
2 // COPYRIGHT NOTES
3 // ---------------
4 // You may use this source code, compile or redistribute it as part of your application 
5 // for free. You cannot redistribute it as a part of a software development 
6 // library without the agreement of the author. If the sources are 
7 // distributed along with the application, you should leave the original 
8 // copyright notes in the source code without any changes.
9 // This code can be used WITHOUT ANY WARRANTIES at your own risk.
10 // 
11 // For the latest updates to this code, check this site:
12 // http://www.masmex.com 
13 // after Sept 2000
14 // 
15 // Copyright(C) 2000 Philip Oldaker <email: philip@masmex.com>
16 //*******************************************************************************
17
18 #include "stdafx.h"
19 #include "ShellDetails.h"
20
21 HRESULT CShellDetails::GetDetailsOf(LPCITEMIDLIST pidl,UINT iColumn,LPSHELLDETAILS pDetail)
22 {
23         HRESULT hr=E_FAIL;
24         if (m_pUnk == NULL)
25                 return hr;
26         IShellFolder2 *pShellFolder2=NULL;
27         hr = m_pUnk->QueryInterface(IID_IShellFolder2,(LPVOID*)&pShellFolder2);
28         if (SUCCEEDED(hr))
29         {
30                 hr = pShellFolder2->GetDetailsOf(pidl,iColumn,pDetail);
31                 pShellFolder2->Release();
32         }
33         else 
34         {
35                 IShellDetails *pShellDetails=NULL;
36                 hr = m_pUnk->QueryInterface(IID_IShellDetails,(LPVOID*)&pShellDetails);
37                 if (SUCCEEDED(hr))
38                 {
39                         hr = pShellDetails->GetDetailsOf(pidl,iColumn,pDetail);
40                         pShellDetails->Release();
41                 }
42         }
43         return hr;
44 }
45
46 bool CShellDetails::IsValidDetails()
47 {
48         return m_pUnk != NULL;
49 }
50
51 void CShellDetails::SetShellDetails(IUnknown *pUnk)
52 {
53         FreeInterfaces();
54         if (pUnk)
55         {
56                 m_pUnk = pUnk;
57                 m_pUnk->AddRef();
58         }
59 }
60
61 CShellDetails::CShellDetails(const CShellDetails &rOther)
62  :      m_pUnk(rOther.m_pUnk)
63 {
64         m_pUnk->AddRef();
65 }
66
67 const CShellDetails &CShellDetails::operator=(const CShellDetails &rOther)
68 {
69         if (this == &rOther)
70                 return *this;
71
72         FreeInterfaces();
73         m_pUnk = rOther.m_pUnk;
74         m_pUnk->AddRef();
75
76         return *this;
77 }
78
79 void CShellDetails::FreeInterfaces()
80 {
81         if (m_pUnk)
82         {
83                 m_pUnk->Release();
84                 m_pUnk = NULL;
85         }
86 }
87
88 CShellDetails::CShellDetails()
89 {
90         m_pUnk = NULL;
91 }
92
93 CShellDetails::~CShellDetails()
94 {
95         FreeInterfaces();
96 }