//---------------------------------------------------------------------------
// getPluginDirectory
//
// returns absolute path where plugins are to be deployed
//---------------------------------------------------------------------------
void CPluginDeploymentEngine::getPluginDirectory(const char* destPath, StringBuffer& sPluginDest) const
{
   sPluginDest.clear().append(destPath); 
   sPluginDest.replace('\\', '/');

   StringBuffer sPluginsDir; //relative path (from ECL server installation directory) for plugins
   m_process.getProp("@pluginsPath", sPluginsDir);

   if (sPluginsDir.length())
   {
      sPluginsDir.replace('\\', '/');
      sPluginsDir.replace('$', ':');

      if (! ::PathIsRelative(sPluginsDir.str()))
         throw MakeStringExceptionDirect(-1, "Plugins path for ECL server must be relative to its installation directory!");

      if (!strncmp(sPluginsDir.str(), "./", 2))
         sPluginsDir.remove(0, 2);

      sPluginDest.append(sPluginsDir);
   }

   const char* pchLast = sPluginDest.str() + sPluginDest.length() - 1;
   if (*pchLast != '/')
      sPluginDest.append('/');
}
bool Cws_accountEx::onMyAccount(IEspContext &context, IEspMyAccountRequest &req, IEspMyAccountResponse &resp)
{
    try
    {
        ISecUser* user = context.queryUser();
        if(user != NULL)
        {
            CDateTime dt;
            user->getPasswordExpiration(dt);
            StringBuffer sb;
            if (dt.isNull())
                sb.append("Never");
            else
            {
                dt.getString(sb);
                sb.replace('T', (char)0);//chop off timestring
            }
            resp.setPasswordExpiration(sb.str());
            resp.setPasswordDaysRemaining(user->getPasswordDaysRemaining());
            resp.setFirstName(user->getFirstName());
            resp.setLastName(user->getLastName());
            resp.setUsername(user->getName());
        }
    }
    catch(IException* e)
    {
        FORWARDEXCEPTION(context, e, ECLWATCH_INTERNAL_ERROR);
    }
    return true;
}
    void processOption(const char *option, const char *value, StringBuffer &eclccCmd, StringBuffer &eclccProgName, IPipeProcess &pipe, bool isLocal)
    {
        if (memicmp(option, "eclcc-", 6) == 0 || *option=='-')
        {
            //Allow eclcc-xx-<n> so that multiple values can be passed through for the same named debug symbol
            const char * start = option + (*option=='-' ? 1 : 6);
            const char * finger = (*start=='-') ? start+1 : start; //support leading double dash
            const char * dash = strrchr(finger, '-');     // position of trailing dash, if present
            StringAttr optName;
            if (dash && (dash != start))
                optName.set(start, dash-start);
            else
                optName.set(start);

            if (!optName)
                return;

            if (stricmp(optName, "hook") == 0)
            {
                if (isLocal)
                    throw MakeStringException(0, "eclcc-hook option can not be set per-workunit");  // for security reasons
                eclccProgName.set(value);
            }
            else if (stricmp(optName, "compileOption") == 0)
                eclccCmd.appendf(" -Wc,%s", value);
            else if (stricmp(optName, "linkOption") == 0)
                eclccCmd.appendf(" -Wl,%s", value);
            else if (stricmp(optName, "includeLibraryPath") == 0)
                eclccCmd.appendf(" -I%s", value);
            else if (stricmp(optName, "libraryPath") == 0)
                eclccCmd.appendf(" -L%s", value);
            else if (strnicmp(optName, "-allow", 6)==0)
            {
                if (isLocal)
                    throw MakeStringException(0, "eclcc-allow option can not be set per-workunit");  // for security reasons
                eclccCmd.appendf(" -%s=%s", optName.get(), value);
            }
            else if (*optName == 'd')
            {
                //Short term work around for the problem that all debug names get lower-cased
                eclccCmd.appendf(" -D%s=%s", optName.get()+1, value);
            }
            else
                eclccCmd.appendf(" -%s=%s", optName.get(), value);
        }
        else if (strchr(option, '-'))
        {
            StringBuffer envVar;
            if (isLocal)
                envVar.append("WU_");
            envVar.append(option);
            envVar.toUpperCase();
            envVar.replace('-','_');
            pipe.setenv(envVar, value);
        }
        else
            eclccCmd.appendf(" -f%s=%s", option, value);
    }
Beispiel #4
0
    void processOption(const char *option, const char *value, StringBuffer &eclccCmd, StringBuffer &eclccProgName, IPipeProcess &pipe, bool isLocal)
    {
        if (memicmp(option, "eclcc-", 6) == 0 || *option=='-')
        {
            //Allow eclcc-xx-<n> so that multiple values can be passed through for the same named debug symbol
            const char * start = option + (*option=='-' ? 1 : 6);
            const char * dash = strchr(start, '-');     // position of second dash, if present
            StringAttr optName;
            if (dash)
                optName.set(start, dash-start);
            else
                optName.set(start);

            if (stricmp(optName, "hook") == 0)
            {
                if (isLocal)
                    throw MakeStringException(0, "eclcc-hook option can not be set per-workunit");  // for security reasons
                eclccProgName.set(value);
            }
            else if (stricmp(optName, "compileOption") == 0)
                eclccCmd.appendf(" -Wc,%s", value);
            else if (stricmp(optName, "includeLibraryPath") == 0)
                eclccCmd.appendf(" -I%s", value);
            else if (stricmp(optName, "libraryPath") == 0)
                eclccCmd.appendf(" -L%s", value);
            else if (stricmp(start, "-allow")==0)
            {
                if (isLocal)
                    throw MakeStringException(0, "eclcc-allow option can not be set per-workunit");  // for security reasons
                eclccCmd.appendf(" -%s=%s", start, value);
            }
            else
                eclccCmd.appendf(" -%s=%s", start, value);
        }
        else if (strchr(option, '-'))
        {
            StringBuffer envVar;
            if (isLocal)
                envVar.append("WU_");
            envVar.append(option);
            envVar.toUpperCase();
            envVar.replace('-','_');
            pipe.setenv(envVar, value);
        }
        else
            eclccCmd.appendf(" -f%s=%s", option, value);
    }
Beispiel #5
0
// Various helper functions for managing build sets
bool connectBuildSet(IPropertyTree* pBuild, IPropertyTree* pBuildSet, StringBuffer& buildSetPath, IConstEnvironment* pConstEnv)
{
  bool rc = true;
  buildSetPath.clear();

  // Get InstallSet file name from BuildSet node
  const char* szVal = pBuild->queryProp(XML_ATTR_URL);
  if (szVal && *szVal)
  {
    buildSetPath = szVal;
    rc = connectionRemoteMachine(buildSetPath, pConstEnv);
    buildSetPath.append(PATHSEPCHAR);
  }
  //szVal = pBuildSet->queryProp(XML_ATTR_PATH);
  //if (szVal && *szVal)
    //buildSetPath.append(szVal).append(PATHSEPCHAR);
  buildSetPath.append("componentfiles").append(PATHSEPCHAR).append("configxml").append(PATHSEPCHAR);
  buildSetPath.replace('\\', PATHSEPCHAR);

  return rc;
}
void AbstractContextI::loadBindings(const String& configuration) throw (Exception)
{
	// replace variables in the config string: eg. "mypath" : "${env/path}" => "mypath" : "c:\\windows ..."

	Anything config;
	try { config = Anything::decodeJSON(configuration, true); }
	catch (const Exception& e) { throw Exception(WITHDETAILS(L"Invalid configuration : " + e->toString() + L"\n" + configuration)); }
	StringBuffer path;
	createBindings(config, path, 1, false);

	StringBuffer buf = configuration;
	while (-1 < buf->indexOf(L"${"))
	{
		InitialContext initialcontext = InitialContext::newInstance();
		int bpos = 0;
		int epos = 0;
		while (bpos < buf->length())
		{
			bpos = buf->indexOf(L"${", bpos);
			if (-1 == bpos) break;
			epos = buf->indexOf(L"}", bpos);
			String variablename = buf->substring(bpos + 2, epos);
			StringAnything variablevalue ;
			initialcontext->lookup(L"/" + variablename, variablevalue);
			StringBuffer value = variablevalue->toString(); 
			if (-1 < value->indexOf(L"${" + variablename + L"}") )
				throw Exception(WITHDETAILS(L"Recursive reference found : ${" + variablename + L"}"));
			buf->replace(bpos, epos + 1, value->toString());
			bpos = epos + 1;
		}

		Anything config;
		try { config = Anything::decodeJSON(buf->toString(), true); }
		catch (const Exception& e) { throw Exception(WITHDETAILS(L"Invalid configuration (2nd pass) : " + e->toString() + L"\n" + buf->toString())); }
		StringBuffer path;
		createBindings(config, path, 1, true);
	}
}
Beispiel #7
0
void CEnvGen::createUpdateTask(const char* action, IPropertyTree * config, const char* param)
{
   if (!param || !(*param)) return;

   if (m_showInputOnly)
   {
      printf("Input as one line format: -%s %s\n", (m_actionAbbrMap.at(action)).c_str(), param);
   }

   StringArray items;
   items.appendList(param, ":");
   if (items.ordinality() < 2)
   {
      throw MakeStringException(CfgEnvErrorCode::InvalidParams,
         "Incorrect input format. At least two item expected: category:component.\n See usage for deail.");
   }

   IPropertyTree * updateTree =  createPTree("Task");
   config->addPropTree("Task", updateTree);

   updateTree->addProp("@operation", action);
   updateTree->addProp("@category", (m_envCategoryMap.at(items.item(0))).c_str());

   //have key and attributes
   StringArray compAndAttrs;
   compAndAttrs.appendList(items.item(1), "@");

   StringArray compAndTarget;
   compAndTarget.appendList(compAndAttrs[0], "%");
   if (!stricmp(action, "remove") && compAndTarget.ordinality() > 1 )
   {
      if (*(compAndTarget.item(1))) updateTree->addProp("@target", compAndTarget.item(1));
   }

   StringArray compAndKey;
   compAndKey.appendList(compAndTarget.item(0), "#");

   updateTree->addProp("@component", compAndKey.item(0));

   if (compAndKey.ordinality() > 1)
   {
      StringArray keyAndClone;
      keyAndClone.appendList(compAndKey.item(1), ATTR_V_SEP);
      updateTree->addProp("@key", keyAndClone.item(0));
      if (keyAndClone.ordinality() > 1)
         updateTree->addProp("@clone", keyAndClone.item(1));
   }

   if (compAndAttrs.ordinality() > 1)
   {
      addUpdateAttributesFromString(updateTree, compAndAttrs.item(1));
      return;
   }

   if (items.ordinality() == 2)
      return;

   int index = 2;

   // selector
   StringArray selectorAndAttrs;
   selectorAndAttrs.appendList(items.item(index), "@");

   StringArray selectorParts;
   selectorParts.appendList(selectorAndAttrs.item(0), "/");

   StringBuffer sbSelector;
   for ( unsigned i = 0; i < selectorParts.ordinality()-1 ; i++)
   {
       if (!sbSelector.isEmpty())
          sbSelector.append("/");
       sbSelector.append(selectorParts.item(i));
   }

   StringArray selectorAndKey;
   selectorAndKey.appendList(selectorParts.item(selectorParts.ordinality()-1), "#");
   if (!sbSelector.isEmpty())
      sbSelector.append("/");
   sbSelector.append(selectorAndKey.item(0));
   sbSelector.replace('#', '@');

   updateTree->addProp("@selector", sbSelector.str());
   if (selectorAndKey.ordinality() > 1)
      updateTree->addProp("@selector-key", selectorAndKey.item(1));

   if (selectorAndAttrs.ordinality() > 1)
   {
      addUpdateAttributesFromString(updateTree, selectorAndAttrs.item(1));
   }

   index++;
   if (items.ordinality() == index) return;

   // children nodes
   IPropertyTree *children = updateTree->addPropTree("Children", createPTree("Children"));
   for ( unsigned i = index; i < items.ordinality() ; i++)
   {
       IPropertyTree *child = children->addPropTree("Child", createPTree("Child"));
       StringArray nameAndAttrs;
       nameAndAttrs.appendList(items.item(i), "@");
       child->addProp("@name", nameAndAttrs.item(0));
       if (nameAndAttrs.ordinality() > 1)
          addUpdateAttributesFromString(child, nameAndAttrs.item(1));
   }

}
   virtual void doWork()
   {
      try
      {
         StringBuffer cmdLine;
         StringBuffer userId;
         StringBuffer password;
         bool bLinux;
         int exitCode = -1;

            if (m_sConfigAddress.length() < 1)
            {
                m_pService->getAccountAndPlatformInfo(m_sAddress.str(), userId, password, bLinux);
            }
            else
            {
                m_pService->getAccountAndPlatformInfo(m_sConfigAddress.str(), userId, password, bLinux);
            }

            if (m_userId.length() < 1 || m_userId.length() < 1)
            {
                //BUG: 9825 - remote execution on linux needs to use individual accounts
                //use userid/password in ESP context for remote execution...
                if (bLinux)
                {
                    userId.clear();
                    password.clear();
                    m_context.getUserID(userId);
                    m_context.getPassword(password);
                }
            }
            else
            {
                userId.clear().append(m_userId);
                password.clear().append(m_password);
            }

#ifdef _WIN32
///#define CHECK_LINUX_COMMAND
#ifndef CHECK_LINUX_COMMAND
#define popen  _popen
#define pclose _pclose

         // Use psexec as default remote control program
         if (bLinux)
         {         
            if (!checkFileExists(".\\plink.exe"))
               throw MakeStringException(ECLWATCH_PLINK_NOT_INSTALLED, "Invalid ESP installation: missing plink.exe to execute the remote program!");

            m_sCommand.replace('\\', '/');//replace all '\\' by '/'

            /* 
            note that if we use plink (cmd line ssh client) for the first time with a computer,
            it generates the following message:

            The server's host key is not cached in the registry. You have no guarantee that the 
            server is the computer you think it is.  The server's key fingerprint is:
            1024 aa:bb:cc:dd:ee:ff:gg:hh:ii:jj:kk:ll:mm:nn:oo:pp
            If you trust this host, enter "y" to add the key to
            PuTTY's cache and carry on connecting.  If you want to carry on connecting just once, 
            without adding the key to the cache, enter "n".If you do not trust this host, press 
            Return to abandon the connection.

            To get around this, we pipe "n" to plink without using its -batch parameter.  We need
            help from cmd.exe to do this though...
            */
                if (!m_useDefaultSSHUserID)
                {
                    cmdLine.appendf("cmd /c \"echo y | .\\plink.exe -ssh -l espuser -i id_rsa.ppk %s bash -c '%s' 2>&1\"",
                        m_sAddress.str(), m_sCommand.str());
                }
                else
                {
                    cmdLine.appendf("cmd /c \"echo y | .\\plink.exe -ssh -l %s -pw %s %s sudo bash -c '%s' 2>&1\"",
                        userId.str(), password.str(), m_sAddress.str(), m_sCommand.str());
                }
         }
         else
         {
            if (!checkFileExists(".\\psexec.exe"))
               throw MakeStringException(ECLWATCH_PSEXEC_NOT_INSTALLED, "Invalid ESP installation: missing psexec.exe to execute the remote program!");

            cmdLine.appendf(".\\psexec \\\\%s -u %s -p %s %s cmd /c %s 2>&1", 
               m_sAddress.str(), userId.str(), password.str(), 
               m_bWait ? "" : "-d", m_sCommand.str());
         }
#else
         if (bLinux)
         {
                if (!m_useDefaultSSHUserID)
                {
                    m_sCommand.replace('\\', '/');//replace all '\\' by '/'
                    cmdLine.appendf("ssh -o StrictHostKeyChecking=no -i /home/espuser/.ssh/id_rsa espuser@%s '%s'", m_sAddress.str(), m_sCommand.str());
                }
                else
                {
                    m_sCommand.replace('\\', '/');//replace all '\\' by '/'
                    cmdLine.appendf("ssh -o StrictHostKeyChecking=no %s '%s'", m_sAddress.str(), m_sCommand.str());
                }
         }
         else
         {
            setResponse("Remote execution from Linux to Windows is not supported!");
            exitCode = 1;
         }
#endif
#else
         if (bLinux)
         {
                if (!m_useDefaultSSHUserID)
                {
                    m_sCommand.replace('\\', '/');//replace all '\\' by '/'
                    cmdLine.appendf("ssh -o StrictHostKeyChecking=no -i /home/espuser/.ssh/id_rsa espuser@%s '%s'", m_sAddress.str(), m_sCommand.str());
                }
                else
                {
                    m_sCommand.replace('\\', '/');//replace all '\\' by '/'
                    cmdLine.appendf("ssh -o StrictHostKeyChecking=no %s '%s'", m_sAddress.str(), m_sCommand.str());
                }
         }
         else
         {
            setResponse("Remote execution from Linux to Windows is not supported!");
            exitCode = 1;
         }
#endif

         if (*cmdLine.str())
         {
            if (m_bWait)
            {
               StringBuffer response, response1;
               exitCode = invoke_program(cmdLine, response);
                    if (exitCode < 0)
                        response1.append("Failed in executing a system command.\n");
                    else
                        response1.append("System command(s) has been executed.\n");

               //remove \n at the end
               int len = response.length();
               if (len > 0 && response.charAt(--len) == '\n')
                  response.setLength(len);

               setResponse(response1.str());
            }
            else
            {
               DWORD runCode;
               ::invoke_program(cmdLine, runCode, false);
               exitCode = (int) runCode;
            }
         }

         setResultCode(exitCode);
      }
      catch(IException* e)
      {
         StringBuffer buf;
         e->errorMessage(buf);
         setResponse(buf.str());
         setResultCode(e->errorCode());
      }
#ifndef NO_CATCHALL
      catch(...)
      {
         setResponse("An unknown exception occurred!");
         setResultCode(-1);
      }
#endif
   }//doWork()
IPropertyTree* CFileSpraySoapBindingEx::createPTreeForXslt(const char* method, const char* dfuwuid)
{
    Owned<IEnvironmentFactory> factory = getEnvironmentFactory();
    Owned<IConstEnvironment> m_constEnv = factory->openEnvironment();
    Owned<IPropertyTree> pEnvRoot = &m_constEnv->getPTree();
    IPropertyTree* pEnvSoftware = pEnvRoot->queryPropTree("Software");

    Owned<IPropertyTree> pRoot = createPTreeFromXMLString("<Environment/>");
    IPropertyTree* pSoftware = pRoot->addPropTree("Software", createPTree("Software"));

    if (pEnvSoftware)
    {
        StringBuffer dfuwuidSourcePartIP, wuxml;
        if(dfuwuid && *dfuwuid)
        {
            Owned<IDFUWorkUnitFactory> dfuwu_factory = getDFUWorkUnitFactory();
            Owned<IConstDFUWorkUnit> dfuwu = dfuwu_factory->openWorkUnit(dfuwuid, false);
            if(dfuwu)
            {   
                dfuwu->toXML(wuxml);

                Owned<IPropertyTree> wu = createPTreeFromXMLString(wuxml.str());
                if (wu)
                {
                    const char* ip = wu->queryProp("Source/Part/@node");
                    if (ip && *ip)
                        dfuwuidSourcePartIP.append(ip);
                }
            }
        }

        Owned<IPropertyTreeIterator> it = pEnvSoftware->getElements("DropZone");
        ForEach(*it)
        {
            IPropertyTree* pDropZone = pSoftware->addPropTree("DropZone", &it->get());
            //get IP Address of the computer associated with this drop zone
            const char* pszComputer = it->query().queryProp("@computer");
            if (!strcmp(pszComputer, "."))
                pszComputer = "localhost";

            StringBuffer xpath;
            xpath.appendf("Hardware/Computer[@name='%s']/@netAddress", pszComputer);

            StringBuffer sNetAddr;
            const char* pszNetAddr = pEnvRoot->queryProp(xpath.str());
            if (strcmp(pszNetAddr, "."))
            {       
                sNetAddr.append(pszNetAddr);
            }
            else
            {
                StringBuffer ipStr;
                IpAddress ipaddr = queryHostIP();
                ipaddr.getIpText(ipStr);
                if (ipStr.length() > 0)
                {
#ifdef MACHINE_IP
                    sNetAddr.append(MACHINE_IP);
#else
                    sNetAddr.append(ipStr.str());
#endif
                }
            }
            pDropZone->addProp("@netAddress", sNetAddr.str());
            if ((dfuwuidSourcePartIP.length() > 0) && (sNetAddr.length() > 0))
            {
                IpAddress ip1(dfuwuidSourcePartIP.str()), ip2(sNetAddr.str());
                if (ip1.ipequals(ip2))              
                    pDropZone->addProp("@sourceNode", "1");
            }

            Owned<IConstMachineInfo> machine;
            if (strcmp(pszNetAddr, "."))
                machine.setown(m_constEnv->getMachineByAddress(sNetAddr.str()));
            else
            {
                machine.setown(m_constEnv->getMachineByAddress(pszNetAddr));
                if (!machine)
                    machine.setown(m_constEnv->getMachineByAddress(sNetAddr.str()));
            }

            if (machine)
            {
                //int os = machine->getOS();
                StringBuffer dir;
                pDropZone->getProp("@directory", dir);
                if (machine->getOS() == MachineOsLinux || machine->getOS() == MachineOsSolaris)
                {         
                    dir.replace('\\', '/');//replace all '\\' by '/'
                    pDropZone->setProp("@linux", "true");
                }
                else
                {       
                    dir.replace('/', '\\');
                    dir.replace('$', ':');
                }
                pDropZone->setProp("@directory", dir);
            }
        }

        //For Spray files on Thor Cluster, fetch all the group names for all the thor instances (and dedup them)
        BoolHash uniqueThorClusterGroupNames;
        it.setown(pEnvSoftware->getElements("ThorCluster"));
        ForEach(*it)
        {
            StringBuffer thorClusterGroupName;
            IPropertyTree& cluster = it->query();
            getClusterGroupName(cluster, thorClusterGroupName);
            if (!thorClusterGroupName.length())
                continue;
            bool* found = uniqueThorClusterGroupNames.getValue(thorClusterGroupName.str());
            if (found && *found)
                continue;

            uniqueThorClusterGroupNames.setValue(thorClusterGroupName.str(), true);
            IPropertyTree* newClusterTree = pSoftware->addPropTree("ThorCluster", &it->get());
            newClusterTree->setProp("@name", thorClusterGroupName.str()); //set group name into @name for spray target
        }

        it.setown(pEnvSoftware->getElements("EclAgentProcess"));
        ForEach(*it)
        {
            IPropertyTree &cluster = it->query();
            const char* name = cluster.queryProp("@name");
            if (!name||!*name)
                continue;
            
            unsigned ins = 0;
            Owned<IPropertyTreeIterator> insts = cluster.getElements("Instance");
            ForEach(*insts) 
            {
                const char *na = insts->query().queryProp("@netAddress");
                if (!na || !*na) 
                {
                    insts->query().setProp("@gname", name);
                    continue;
                }
                
                SocketEndpoint ep(na);
                if (ep.isNull())
                    continue;

                ins++;
                StringBuffer gname("hthor__");
                //StringBuffer gname;
                gname.append(name);
                if (ins>1)
                    gname.append('_').append(ins);

                insts->query().setProp("@gname", gname.str());

            }

            pSoftware->addPropTree("EclAgentProcess", &it->get());
        }

        if (stricmp(method, "CopyInput") == 0) //Limit for this method only
        {
            it.setown(pEnvSoftware->getElements("RoxieCluster"));
            ForEach(*it)
                pSoftware->addPropTree("RoxieCluster", &it->get());
        }

        if (wuxml.length() > 0)
            pSoftware->addPropTree("DfuWorkunit", createPTreeFromXMLString(wuxml.str()));
    }
    return pRoot.getClear();
}
void CPicturesSettings::OnCbnSelchangePicturesComboSynctype()
{
    // Supported data format
    StringBuffer supportedData;
    
    CString ss(" "), ss1;        
    ss1.LoadString(IDS_SUPPORTED_FORMAT);
    ss.Append(ss1);
    
    CString And;
    And.LoadString(IDS_STRING_AND);
    StringBuffer and(" ");
    and.append(ConvertToChar(And));
    and.append(" ");
       
    
    StringBuffer data = ssconf->getProperty(PROPERTY_EXTENSION);    
    if (data.empty() == false) {
       
        supportedData = ConvertToChar(ss);
        
        StringBuffer data = ssconf->getProperty(PROPERTY_EXTENSION);    
        data.upperCase();
        supportedData.append(data);
        
        int val = supportedData.rfind(",.");
        if (val != StringBuffer::npos) {
            supportedData.replace(",.", and.c_str(), val);
        }
        supportedData.replaceAll(",.",", ");
        supportedData.replaceAll(".","");  
        supportedData.append(".");
    }
   
    CString suppData = supportedData;

    int index = 0;
    if (lstSyncType.GetCount() > 1) {
        index = lstSyncType.GetCurSel();
    } else {
        // Fixed, 1 synctype only, get from config.
        index = getSyncTypeIndex(ssconf->getSync());
    }

    CString s1;
    switch (index) {
        case 0:
            s1.LoadString(IDS_TWO_WAY_LABEL_PICT_SUMMARY);
            s1.Append(suppData);
            SetDlgItemText(IDC_PICTURES_SYNC_DIRECTION_LABEL, s1);
            break;
        case 1:
            s1.LoadString(IDS_DOWNLOAD_ONLY_LABEL_PICT_SUMMARY);        
            s1.Append(suppData);
            SetDlgItemText(IDC_PICTURES_SYNC_DIRECTION_LABEL, s1);
            break;
        case 2:
            s1.LoadString(IDS_UPLOAD_ONLY_LABEL_PICT_SUMMARY);
            s1.Append(suppData);
            SetDlgItemText(IDC_PICTURES_SYNC_DIRECTION_LABEL, s1);
            break;
    }
}
String AbstractContextI::loadValueFromURL(const String& urlstring) const throw (Exception)
{
	String result;
	StringBuffer buf;
	buf->append(urlstring);
	if (0 == buf->indexOf(L"http://"))
	{
		URL url = new URLI(urlstring);
		HttpURLConnection httpurlconnection;
		url->openConnection()->downcast(httpurlconnection);
		if (verboseOutput()) cout << "JNDI context : Get response from url : " << urlstring << endl;
		int rc = httpurlconnection->getResponseCode();
		UTF8StringBuffer cbuf;
#if defined (_WINDOWS_SOURCE)
		cbuf->append(getenv("TEMP"));
		cbuf->append("\\");
		cbuf->append(getenv("USERNAME"));
		cbuf->append(".");
#else
		cbuf->append(getenv("USER_HOME"));
		cbuf->append("/.");
#endif
		cbuf->append(urlstring->toMD5());
		cbuf->append(".properties");
		String cachefilepath = cbuf->toString()->toLowerCase();
		if (200 != rc) 
		{
			if (verboseOutput()) cout << "JNDI context : HTTP status = " << rc << endl;
			if (verboseOutput()) cout << "JNDI context : Trying to load from cached file : " << cachefilepath << endl;
			InputStream file = new FileInputStreamI(cachefilepath);
			UTF8String content;
			file->read(content, 0);
			file->close();
			result = content->toString();
		}
		else
		{
			String response = httpurlconnection->getResponseMessage();
			Writer file = new FileWriterI(cachefilepath);
			file->write(response);
			file->close();
			if (verboseOutput()) cout << "JNDI context : Caching to file : " << cachefilepath << endl;
			result = response;
		}
	}
	else if (0 == buf->indexOf(L"file://"))
	{
		result = loadValueFromFile(urlstring);
	}
	else
	{
		throw NamingException(WITHDETAILS(L"Unsupported URI format: " + urlstring));
	}
	StringBuffer b = result;
	while (-1 < b->indexOf(L"${"))
	{
		InitialContext initialcontext = InitialContext::newInstance();
		int bpos = 0;
		int epos = 0;
		while (bpos < b->length())
		{
			bpos = b->indexOf(L"${", bpos);
			if (-1 == bpos) break;
			epos = b->indexOf(L"}", bpos);
			String variablename = b->substring(bpos + 2, epos);
			StringAnything variablevalue ;
			initialcontext->lookup(L"/" + variablename, variablevalue);
			StringBuffer value = variablevalue->toString(); 
			if (-1 < value->indexOf(L"${" + variablename + L"}") )
				throw Exception(WITHDETAILS(L"Recursive reference found : ${" + variablename + L"}"));
			b->replace(bpos, epos + 1, value->toString());
			bpos = epos + 1;
		}
	}
	return b->toString();
}
void CVideosSettings::OnCbnSelchangeVideosComboSynctype()
{
    // Supported data format
    StringBuffer supportedData;
    
    CString ss(" "), ss1;        
    ss1.LoadString(IDS_SUPPORTED_FORMAT);
    ss.Append(ss1);
    
    CString And;
    And.LoadString(IDS_STRING_AND);
    StringBuffer and(" ");
    and.append(ConvertToChar(And));
    and.append(" ");
       
    
    StringBuffer data = ssconf->getProperty(PROPERTY_EXTENSION);    
    if (data.empty() == false) {
       
        supportedData = ConvertToChar(ss);
        
        StringBuffer data = ssconf->getProperty(PROPERTY_EXTENSION);    
        data.upperCase();
        supportedData.append(data);
        
        int val = supportedData.rfind(",.");
        if (val != StringBuffer::npos) {
            supportedData.replace(",.", and.c_str(), val);
        }
        supportedData.replaceAll(",.",", ");
        supportedData.replaceAll(".","");    
        supportedData.append(".");
    }
   
    /*
    CString s2;
    s2.LoadString(IDS_MEDIA_HUB_VIDEO_MAX_SIZE);
    StringBuffer s, sss;    
    s = ConvertToChar(s2);
    sss.sprintf(s.c_str(), (int)SAPI_MAX_VIDEO_SIZE/1024/1024);
    supportedData.append(" ");
    supportedData.append(sss);
    */
    CString s2;
    s2.LoadString(IDS_MEDIA_HUB_VIDEO_MAX_SIZE);
    WCHAR tmp[1024];
    wsprintf(tmp, s2.GetBuffer(), (int)SAPI_MAX_VIDEO_SIZE/1024/1024);
    wstring w1 = tmp;
    WCHAR* tmp2 = toWideChar(supportedData.c_str());
    wstring w2 = tmp2;
    delete [] tmp2;

    w2.append(L" ");
    w2.append(w1);

    CString suppData(w2.c_str()); //supportedData;

    int index = 0;
    if (lstSyncType.GetCount() > 1) {
        index = lstSyncType.GetCurSel();
    } else {
        // Fixed, 1 synctype only, get from config.
        index = getSyncTypeIndex(ssconf->getSync());
    }

    CString s1;
    switch (index) {
        case 0:
            s1.LoadString(IDS_TWO_WAY_LABEL_VIDEO_SUMMARY);
            s1.Append(suppData);
            SetDlgItemText(IDC_VIDEOS_SYNC_DIRECTION_LABEL, s1);
            break;
        case 1:
            s1.LoadString(IDS_DOWNLOAD_ONLY_LABEL_VIDEO_SUMMARY);        
            s1.Append(suppData);
            SetDlgItemText(IDC_VIDEOS_SYNC_DIRECTION_LABEL, s1);
            break;
        case 2:
            s1.LoadString(IDS_UPLOAD_ONLY_LABEL_VIDEO_SUMMARY);
            s1.Append(suppData);
            SetDlgItemText(IDC_VIDEOS_SYNC_DIRECTION_LABEL, s1);
            break;
    }
}