blob: 2299338315f4c05f69f1b7bf58e3efa7e67a5aa7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
// FilePlugins.cpp
#include "StdAfx.h"
#include "Common/MyCom.h"
#include "../Agent/Agent.h"
#include "FilePlugins.h"
#include "PluginLoader.h"
#include "StringUtils.h"
using namespace NRegistryAssociations;
int CExtDatabase::FindExtInfoBig(const UString &ext)
{
for (int i = 0; i < ExtBigItems.Size(); i++)
if (ExtBigItems[i].Ext.CompareNoCase(ext) == 0)
return i;
return -1;
}
int CExtDatabase::FindPlugin(const UString &plugin)
{
for (int i = 0; i < Plugins.Size(); i++)
if (Plugins[i].Name.CompareNoCase(plugin) == 0)
return i;
return -1;
}
void CExtDatabase::Read()
{
/*
CObjectVector<CExtInfo> extItems;
ReadInternalAssociations(extItems);
*/
ReadFileFolderPluginInfoList(Plugins);
/*
for (int i = 0; i < extItems.Size(); i++)
{
const CExtInfo &extInfo = extItems[i];
CExtInfoBig extInfoBig;
extInfoBig.Ext = extInfo.Ext;
extInfoBig.Associated = false;
for (int p = 0; p < extInfo.Plugins.Size(); p++)
{
int pluginIndex = FindPlugin(extInfo.Plugins[p]);
if (pluginIndex >= 0)
extInfoBig.PluginsPairs.Add(CPluginEnabledPair(pluginIndex, true));
}
ExtBigItems.Add(extInfoBig);
}
*/
for (int pluginIndex = 0; pluginIndex < Plugins.Size(); pluginIndex++)
{
const CPluginInfo &pluginInfo = Plugins[pluginIndex];
CPluginLibrary pluginLibrary;
CMyComPtr<IFolderManager> folderManager;
if (pluginInfo.FilePath.IsEmpty())
folderManager = new CArchiveFolderManager;
else if (pluginLibrary.LoadAndCreateManager(pluginInfo.FilePath,
pluginInfo.ClassID, &folderManager) != S_OK)
continue;
CMyComBSTR extBSTR;
if (folderManager->GetExtensions(&extBSTR) != S_OK)
return;
const UString ext2 = (const wchar_t *)extBSTR;
UStringVector exts;
SplitString(ext2, exts);
for (int i = 0; i < exts.Size(); i++)
{
const UString &ext = exts[i];
#ifdef UNDER_CE
if (ext == L"cab")
continue;
#endif
int index = FindExtInfoBig(ext);
if (index < 0)
{
CExtInfoBig extInfo;
extInfo.PluginsPairs.Add(CPluginEnabledPair(pluginIndex, false));
extInfo.Associated = false;
extInfo.Ext = ext;
ExtBigItems.Add(extInfo);
}
else
{
CExtInfoBig &extInfo = ExtBigItems[index];
int pluginIndexIndex = extInfo.FindPlugin(pluginIndex);
if (pluginIndexIndex < 0)
extInfo.PluginsPairs.Add(CPluginEnabledPair(pluginIndex, false));
}
}
}
}
void CExtDatabase::Save()
{
/*
CObjectVector<CExtInfo> extItems;
for (int i = 0; i < ExtBigItems.Size(); i++)
{
const CExtInfoBig &extInfoBig = ExtBigItems[i];
CExtInfo extInfo;
// extInfo.Enabled = extInfoBig.Associated;
extInfo.Ext = extInfoBig.Ext;
for (int p = 0; p < extInfoBig.PluginsPairs.Size(); p++)
{
CPluginEnabledPair pluginPair = extInfoBig.PluginsPairs[p];
if (pluginPair.Enabled)
extInfo.Plugins.Add(Plugins[pluginPair.Index].Name);
}
extItems.Add(extInfo);
}
WriteInternalAssociations(extItems);
*/
}
|