/*!
   * @if jp
   * @brief 途中のコンテキストを再帰的に bind しながら Object を bind する
   * @else
   * @brief Bind intermediate context recursively and bind object
   * @endif
   */
  void CorbaNaming::bindRecursive(CosNaming::NamingContext_ptr context,
				  const CosNaming::Name& name,
				  CORBA::Object_ptr obj)
    throw (SystemException, CannotProceed, InvalidName, AlreadyBound)
  {
    CORBA::ULong len(name.length());
    CosNaming::NamingContext_var cxt;
    cxt = CosNaming::NamingContext::_duplicate(context);
    
    for (CORBA::ULong i = 0; i < len; ++i)
      {
	if (i == (len - 1))
	  { // this operation may throw AlreadyBound, 
	    cxt->bind(subName(name, i, i), obj);
	    return;
	  }
	else
	  { // If the context is not a NamingContext, CannotProceed is thrown
	    if (isNamingContext(cxt))
	      cxt = bindOrResolveContext(cxt, subName(name, i, i));
	    else
	      throw CannotProceed(cxt, subName(name, i));
	  }
      }
    return;
  }
  /*!
   * @if jp
   * @brief 途中のコンテキストを bind しながら Object を rebind する
   * @else
   * @brief Bind intermediate context recursively and rebind object
   * @endif
   */
  void CorbaNaming::rebindRecursive(CosNaming::NamingContext_ptr context,
				    const CosNaming::Name& name,
				    CORBA::Object_ptr obj)
    throw (SystemException, CannotProceed, InvalidName)
  {
    CORBA::ULong len(name.length());
    CosNaming::NamingContext_var cxt;
    cxt = CosNaming::NamingContext::_duplicate(context);
    
    for (CORBA::ULong i = 0; i < len; ++i)
      {
	if (i == (len - 1))
	  {
	    cxt->rebind(subName(name, i, i), obj);
	    return;
	  }
	else
	  { // If the context is not a NamingContext, CannotProceed is thrown
	    if (isNamingContext(cxt))
	      {
		try
		  {
		    cxt = cxt->bind_new_context(subName(name, i, i));
		  }
		catch (AlreadyBound& e)
		  {
		    (void)(e);
		    cxt = CosNaming::
		      NamingContextExt::
		      _narrow(cxt->resolve(subName(name, i, i)));
		  }
	      }
	    else
	      throw CannotProceed(cxt, subName(name, i));
	  }
      }
    return;
  }
nsresult
sbStringBundle::ApplySubstitutions(nsAString& aString)
{
  nsresult rv;

  // Apply embedded bundle strings.
  nsAutoString processedString(aString);
  PRInt32 subStartIndex = 0;
  PRInt32 subEndIndex = -1;
  while (1) {
    // Find the next embedded bundle string.
    PRInt32 subLength;
    subStartIndex = processedString.Find("&",
                                         static_cast<PRUint32>(subStartIndex));
    if (subStartIndex < 0)
      break;
    subEndIndex = processedString.Find(";",
                                       static_cast<PRUint32>(subStartIndex));
    if (subEndIndex < 0)
      break;
    subLength = subEndIndex + 1 - subStartIndex;

    // Get the bundle string name.
    nsAutoString subName(Substring(processedString,
                                   subStartIndex + 1,
                                   subLength - 2));

    // Get the bundle string, special casing "&amp;".
    nsAutoString subString;
    if (subName.Equals(NS_LITERAL_STRING("amp"))) {
      subString.Assign(NS_LITERAL_STRING("&"));
    } else {
      rv = GetStringFromName(subName.get(), getter_Copies(subString));
      if (NS_FAILED(rv))
        subString.Truncate();
    }

    // Apply the embedded bundle string.
    processedString.Replace(subStartIndex, subLength, subString);

    // Continue processing after the bundle string.
    subStartIndex += subString.Length();
  }

  // Return results.
  aString.Assign(processedString);

  return NS_OK;
}
Beispiel #4
0
void CDropbox::CommandContent(void *arg)
{
	CommandParam *param = (CommandParam*)arg;

	char *path = (char*)param->data;
	if (path == NULL)
		path = "";

	ptrA token(db_get_sa(NULL, MODULE, "TokenSecret"));
	ptrA encodedPath(mir_utf8encode(path));
	GetMetadataRequest request(token, encodedPath);
	NLHR_PTR response(request.Send(param->instance->hNetlibConnection));

	if (response == NULL || response->resultCode != HTTP_STATUS_OK) {
		ProtoBroadcastAck(MODULE, param->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, param->hProcess, 0);
		return;
	}

	JSONNode root = JSONNode::parse(response->pData);
	if (root.empty()) {
		ProtoBroadcastAck(MODULE, param->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, param->hProcess, 0);
		return;
	}

	CMStringA message;
	bool isDir = root.at("is_dir").as_bool();
	if (!isDir)
		message.AppendFormat("\"%s\" %s", encodedPath, T2Utf(TranslateT("is file")));
	else {
		JSONNode content = root.at("contents").as_array();
		for (size_t i = 0; i < content.size(); i++) {
			JSONNode item = content[i];
			if (item.empty()) {
				if (i == 0)
					message.AppendFormat("\"%s\" %s", encodedPath, T2Utf(TranslateT("is empty")));
				break;
			}

			CMStringA subName(item.at("path").as_string().c_str());
			message.AppendFormat("%s\n", (subName[0] == '/') ? subName.Mid(1) : subName);
		}
	}

	ProtoBroadcastAck(MODULE, param->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, param->hProcess, 0);
	CallContactService(param->instance->GetDefaultContact(), PSR_MESSAGE, 0, (LPARAM)message.GetBuffer());
}
static void serialize_sub(const char* fontName, SkTypeface::Style style, SkWStream* wstream) {
    SkFontDescriptor desc(style);
    SkString subName(SUBNAME_PREFIX);
    subName.append(fontName);
    const char* familyName = subName.c_str();
    desc.setFamilyName(familyName);
    desc.serialize(wstream);
#if WHITELIST_DEBUG
    for (int i = 0; i < whitelistCount; ++i) {
        if (!strcmp(fontName, whitelist[i].fFontName)) {
            if (!whitelist[i].fSerializedSub) {
                whitelist[i].fSerializedSub = true;
                SkDebugf("%s %s\n", __FUNCTION__, familyName);
            }
            break;
        }
    }
#endif
}