[prev in list] [next in list] [prev in thread] [next in thread]
List: helix-server-cvs
Subject: [Server-cvs] license/slicensepln server_license.cpp, 1.17.38.2, 1.17.38.3
From: zhxinx () helixcommunity ! org
Date: 2013-10-17 8:29:14
[Download RAW message or body]
Update of /cvsroot/server/license/slicensepln
In directory cvs01.internal.helixcommunity.org:/tmp/cvs-serv3244/license/slicensepln
Modified Files:
Tag: Cobra_MVP
server_license.cpp
Log Message:
[cobra][CR] load license file from peripheral storage
Project
=====
Cobra(Server)
Overview
========
For Android TV/setbox, there is need from PO to load license file from peripheral \
storage and copy it to local license directory. The use case is used by post-sales \
persons to fix license related issues. The attached patch is used for this.
Besides, original file has indent issue. Modify indents involved.
Branch: Cobra_MVP
Files Modified
===========
server/license/slicensepln/pub/server_license.h
server/license/slicensepln/server_license.cpp
Verified platform
===========
MStar platform.
UT passed
Index: server_license.cpp
===================================================================
RCS file: /cvsroot/server/license/slicensepln/server_license.cpp,v
retrieving revision 1.17.38.2
retrieving revision 1.17.38.3
diff -u -d -r1.17.38.2 -r1.17.38.3
--- server_license.cpp 9 Sep 2013 04:20:48 -0000 1.17.38.2
+++ server_license.cpp 17 Oct 2013 08:29:02 -0000 1.17.38.3
@@ -83,6 +83,33 @@
#define INADDR_NONE 0xffffffff
#endif
+#ifdef ANDROID
+struct storageMappingItem
+{
+ const char* storage;
+ const char* storagePath;
+};
+
+static storageMappingItem strUsbPartitons[4] =
+{
+#ifdef MIPS
+ {"sda1", "/mnt/removable/sda1/License"},
+ {"sdb1", "/mnt/removable/sdb1/License"},
+ {"sdc1", "/mnt/removable/sdc1/License"},
+ {"sdd1", "/mnt/removable/sdd1/License"},
+#else
+ {"sda1", "/mnt/usb/sda1/License"},
+ {"sdb1", "/mnt/usb/sdb1/License"},
+ {"sdc1", "/mnt/usb/sdc1/License"},
+ {"sdd1", "/mnt/usb/sdd1/License"}
+#endif
+};
+
+#define DEFAULTSTORAGE "/mnt/sdcard/License"
+#define PROCPARTITIONFILESIZE 2048
+
+#endif
+
ServerLicense::ServerLicense(IUnknown* pContext)
: m_ulLicenseIndex(0)
, m_bDisableAggregation(FALSE)
@@ -134,76 +161,76 @@
hResult = m_pRegistry->GetStrByName("config.LicenseDirectory", pBuffer);
if ((hResult == HXR_OK) && pBuffer)
{
- pLicDir = pBuffer->GetBuffer();
- if (pLicDir && strlen((char*)pLicDir))
- {
- pFileFinder = CFindFile::CreateFindFile((char*)pLicDir, 0, "*");
- if (pFileFinder)
- {
- // Iterate through all files in the license directory
- pFilename = pFileFinder->FindFirst();
- while (pFilename)
- {
- // Load and parse this file
- pFilename = pFileFinder->GetCurFilePath();
- if (!FileIO::is_directory(pFilename))
- {
- HandleLicenseFile(pFilename, bOEM);
- }
- pFilename = pFileFinder->FindNext();
- }
+ pLicDir = pBuffer->GetBuffer();
+ if (pLicDir && strlen((char*)pLicDir))
+ {
+ HandleLicenseInDirectory((char*)pLicDir, bOEM);
+#ifdef ANDROID
+ // No valid license loaded from default license directory
+ if (m_ulLicenseIndex == 0)
+ {
+ // Check with /mnt/sdcard/license at first
+ HandleLicenseInDirectory(DEFAULTSTORAGE, bOEM, TRUE, pLicDir);
- // Combine files into one summary
- ComposeLicenseSummary();
- }
- else
- {
- LICENSE_ERRMSG("Out of Memory. Unable to parse license files.\n");
- hResult = HXR_FAIL;
- }
- }
- else
- {
- IHXBuffer* pbufProductName = NULL;
- m_pProductVersion->ProductName(pbufProductName);
- LICENSE_ERRMSG("Invalid LicenseDirectory "
- "specified in server configuration. Please ensure that your "
- "configuration file contains a LicenseDirectory, and that "
- "the LicenseDirectory specifies the full path to the directory "
- "containing your %s license files.\n", pbufProductName->GetBuffer());
- hResult = HXR_FAIL;
- HX_RELEASE(pbufProductName);
- }
+ // Check whether other peripheral storage contains valid license \
file + if (m_ulLicenseIndex == 0)
+ {
+ char pProcstorages[PROCPARTITIONFILESIZE];
+ memset(pProcstorages, 0, PROCPARTITIONFILESIZE);
+ FILE* fp = ::fopen("/proc/partitions", "rb");
+ if(fp)
+ {
+ int size = ::fread(pProcstorages, 1, PROCPARTITIONFILESIZE, \
fp); + int nUsbPartitonsNumber = sizeof(strUsbPartitons) / \
sizeof(strUsbPartitons[0]); + for(int pos = 0; pos < \
nUsbPartitonsNumber; pos++) + {
+ if(NULL != strstr(pProcstorages, \
strUsbPartitons[pos].storage)) + {
+ \
HandleLicenseInDirectory(strUsbPartitons[pos].storagePath, bOEM, TRUE, pLicDir); + \
} + }
+ ::fclose(fp);
+ }
+ }
+ }
+#endif
+
+ // Combine files into one summary
+ ComposeLicenseSummary();
+ }
+ else
+ {
+ LICENSE_ERRMSG("Out of Memory. Unable to parse license files.\n");
+ hResult = HXR_FAIL;
+ }
}
else
{
IHXBuffer* pbufProductName = NULL;
m_pProductVersion->ProductName(pbufProductName);
-
LICENSE_ERRMSG("Invalid LicenseDirectory "
- "specified in server configuration. Please ensure that your "
- "configuration file contains a LicenseDirectory, and that "
- "the LicenseDirectory specifies the full path to the directory "
- "containing your %s license files.\n", pbufProductName->GetBuffer());
- hResult = HXR_FAIL;
+ "specified in server configuration. Please ensure that your "
+ "configuration file contains a LicenseDirectory, and that "
+ "the LicenseDirectory specifies the full path to the directory "
+ "containing your %s license files.\n", pbufProductName->GetBuffer());
+ hResult = HXR_FAIL;
HX_RELEASE(pbufProductName);
}
// Make "license." composite key read-only
// m_pRegistry->SetReadOnly("license", TRUE, m_pProc);
- if ((m_ulLicenseIndex == 0) &&
- (hResult == HXR_OK))
+ if ((m_ulLicenseIndex == 0) && (hResult == HXR_OK))
{
- if (!pLicDir || strcmp((const char*)pLicDir, "nonexistent"))
- {
- LICENSE_ERRMSG("The server did not detect "
- "a license key in the License Key Directory: \"%s\". "
- "Please locate your license key provided by RealNetworks "
- "and copy to the License Key Directory.\n",
- pLicDir ? (char*)pLicDir : "");
- hResult = HXR_FAIL;
- }
+ if (!pLicDir || strcmp((const char*)pLicDir, "nonexistent"))
+ {
+ LICENSE_ERRMSG("The server did not detect "
+ "a license key in the License Key Directory: \"%s\". "
+ "Please locate your license key provided by RealNetworks "
+ "and copy to the License Key Directory.\n",
+ pLicDir ? (char*)pLicDir : "");
+ hResult = HXR_FAIL;
+ }
}
HX_DELETE(pFileFinder);
@@ -1172,6 +1199,52 @@
return HXR_FAIL;
}
+STDMETHODIMP
+ServerLicense::HandleLicenseInDirectory(const char* path, HXBOOL bOEM, HXBOOL bCopy, \
const char* licDirectory) +{
+ CFindFile* pFileFinder = CFindFile::CreateFindFile(path, 0, "*");
+ char* pFilename = NULL;
+ if (pFileFinder)
+ {
+ // Iterate through all files in the license directory
+ pFilename = pFileFinder->FindFirst();
+ while (pFilename)
+ {
+ // Load and parse this file
+ pFilename = pFileFinder->GetCurFilePath();
+ if (!FileIO::is_directory(pFilename))
+ {
+ HandleLicenseFile(pFilename, bOEM);
+ }
+
+ // Do backup for the
+#ifdef ANDROID
+ if (bCopy && licDirectory != NULL && m_ulLicenseIndex != 0)
+ {
+ char tmpBuf[1024];
+ int n;
+ char pLicName[512];
+ strcpy(pLicName, licDirectory);
+ strcat(pLicName, "/usb.lic");
+ // no cp function in Android, read/write to mock one
+ FILE* fin = ::fopen(pFilename, "rb");
+ FILE* fout = ::fopen(pLicName, "wb");
+ while ((n = ::fread(tmpBuf, sizeof(char), 1024, fin)) > 0)
+ {
+ ::fwrite(tmpBuf, sizeof(char), n, fout);
+ }
+ // Here for Android version, no need to consider aggregate condition
+ break;
+ }
+#endif
+ pFilename = pFileFinder->FindNext();
+ }
+
+ }
+
+ return HXR_OK;
+}
+
/*
This method directly writes to standard out as well as the
error log. We use this instead of the Error Handler since the
_______________________________________________
Server-cvs mailing list
Server-cvs@helixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/server-cvs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic