Example #1
0
PString SoundFX::GetModTypeString(int32 index)
{
	PString type;

	type.LoadString(res, IDS_SFX_MIME);
	return (type);
}
Example #2
0
PString SoundFX::GetDescription(int32 index)
{
	PString description;

	description.LoadString(res, IDS_SFX_DESCRIPTION);
	return (description);
}
Example #3
0
bool
ScriptablePluginObject::Invoke(NPIdentifier name, const NPVariant *args,
                               uint32_t argCount, NPVariant *result)
{
  if (name == sendCmd_id)
  {
	if ( argCount < 1 )
	{
		return false;
	}

	PString strParam = "";
	NPString npStr = NPVARIANT_TO_STRING( args[0] );
	for (unsigned int i=0; i<npStr.utf8length; i++)
	{
		strParam += npStr.utf8characters[ i ];
	}


	PString strResult = g_NativeLogic.InvokeFunction( strParam );

	char* pszName = (char*)NPN_MemAlloc( strResult.GetSize() + 1 );
	strcpy( pszName, strResult );
    STRINGZ_TO_NPVARIANT(pszName, *result);

    return PR_TRUE;
  }

  return PR_FALSE;
}
Example #4
0
pbool PIni::load(const pchar *filename)
{
    //
    // Look for the file in the specified path
    //
    const pchar* pathList[] =
    {
        ".",
        pPathGetApplicationDirectory(),
        pPathGetExternalStoragePath(),
    };

    for (size_t i = 0; i < sizeof(pathList) / sizeof(pathList[0]); ++i)
    {
        if (pathList[i] != P_NULL)
        {
            PString cfgPath = PString(pathList[i]) + PString(pPathGetDelimiter()) + PString(filename);
            PFile *fp = pfopen(cfgPath.c_str(), "rb");
            if (fp != P_NULL)
            {
                if (ini_parse_file((FILE *)(fp), iniHandler_internal, this) < 0)
                {
                    PLOG_ERROR("Failed to parse %s", cfgPath.c_str());
                    pfclose(fp);
                    return false;
                }
                pfclose(fp);

                return true;
            }
        }
    }

    //
    // Look for the ini file in asset
    //
    PAsset asset = pAssetOpen(filename);
    if (pAssetIsValid(&asset))
    {
        PIniBufferObject iniBufferObject;
        iniBufferObject.m_buffer = (const pchar*)pAssetGetBuffer(&asset);
        iniBufferObject.m_bufferSize = pAssetGetSize(&asset);
        iniBufferObject.m_position = 0;
        
        if (ini_parse_buffer(&iniBufferObject, iniHandler_internal, this) < 0)
        {
            PLOG_ERROR("Failed to parse %s", filename);
            pAssetClose(&asset);
            return false;
        }

        pAssetClose(&asset);
        
        return true;
    }

    PLOG_ERROR("Failed to find %s", filename);
    
    return false;
}
Example #5
0
PString JamCracker::GetDescription(int32 index)
{
	PString description;

	description.LoadString(res, IDS_JAM_DESCRIPTION);
	return (description);
}
Example #6
0
PString DecruncherAgent::GetName(int32 index)
{
	PString name;

	name.LoadString(res, IDS_DECRUNCH_NAME);
	return (name);
}
Example #7
0
PString JamCracker::GetName(int32 index)
{
	PString name;

	name.LoadString(res, IDS_JAM_NAME);
	return (name);
}
Example #8
0
PString DecruncherAgent::GetDescription(int32 index)
{
	PString description;

	description.LoadString(res, IDS_DECRUNCH_DESCRIPTION);
	return (description);
}
bool Opal::Sip::EndPoint::OnReceivedMESSAGE (OpalTransport & transport,
                                             SIP_PDU & pdu)
{
  PString *last = NULL;
  PString *val = NULL;

  PString from = pdu.GetMIME().GetFrom();   
  PINDEX j = from.Find (';');
  if (j != P_MAX_INDEX)
    from = from.Left(j); // Remove all parameters
  j = from.Find ('<');
  if (j != P_MAX_INDEX && from.Find ('>') == P_MAX_INDEX)
    from += '>';

  PWaitAndSignal m(msgDataMutex);
  last = msgData.GetAt (SIPURL (from).AsString ());
  if (!last || *last != pdu.GetMIME ().GetFrom ()) {

    val = new PString (pdu.GetMIME ().GetFrom ());
    msgData.SetAt (SIPURL (from).AsString (), val);

    SIPURL uri = from;
    uri.Sanitise (SIPURL::RequestURI);
    std::string display_name = (const char *) uri.GetDisplayName ();
    std::string message_uri = (const char *) uri.AsString ();
    std::string _message = (const char *) pdu.GetEntityBody ();

    runtime.run_in_main (sigc::bind (sigc::ptr_fun (push_message_in_main), dialect, message_uri, display_name, _message));
  }

  return SIPEndPoint::OnReceivedMESSAGE (transport, pdu);
}
Example #10
0
PString MediaKitAgent::GetDescription(int32 index)
{
	PString description;

	description.LoadString(res, IDS_MEDIAKIT_DESCRIPTION);
	return (description);
}
Example #11
0
PString JamCracker::GetModTypeString(int32 index)
{
	PString type;

	type.LoadString(res, IDS_JAM_MIME);
	return (type);
}
Example #12
0
PString SoundFX::GetName(int32 index)
{
	PString name;

	name.LoadString(res, IDS_SFX_NAME);
	return (name);
}
Example #13
0
bool
Opal::Sip::EndPoint::OnReceivedMESSAGE (OpalTransport & transport,
					SIP_PDU & pdu)
{
  if (pdu.GetMIME().GetContentType(false) != "text/plain")
    return false; // Ignore what we do not handle.

  PString from = pdu.GetMIME().GetFrom();
  PINDEX j = from.Find (';');
  if (j != P_MAX_INDEX)
    from = from.Left(j); // Remove all parameters
  j = from.Find ('<');
  if (j != P_MAX_INDEX && from.Find ('>') == P_MAX_INDEX)
    from += '>';

  SIPURL uri = from;
  uri.Sanitise (SIPURL::RequestURI);
  std::string display_name = (const char *) uri.GetDisplayName ();
  std::string message_uri = (const char *) uri.AsString ();
  std::string _message = (const char *) pdu.GetEntityBody ();

  Ekiga::Runtime::run_in_main (boost::bind (&Opal::Sip::EndPoint::push_message_in_main, this, message_uri, display_name, _message));

  return SIPEndPoint::OnReceivedMESSAGE (transport, pdu);
}
PString APServerCommunication::SendCommand(void *handle, PString command)
{
	BMessenger messenger(NULL, serverLooper);
	BMessage message(APSERVER_MSG_DATA);
	BMessage reply;
	const char *replyCmd;
	char *cmdStr;

	// Just add the looper and command to the message
	message.AddPointer("ClientLooper", handle);
	message.AddString("Command", (cmdStr = command.GetString()));
	command.FreeBuffer(cmdStr);

	// Send the command and wait for the reply
	messenger.SendMessage(&message, &reply);

	if (reply.what != APSERVER_MSG_OK)
	{
		// The server couldn't understand or run the command
		//
		// Find the error string
		if (reply.FindString("Result", &replyCmd) == B_OK)
			return (PString("ERR=") + replyCmd);

		return ("ERR=0");
	}

	// Extract the answer from the reply message
	if (reply.FindString("Result", &replyCmd) != B_OK)
		return ("");

	return (replyCmd);
}
Example #15
0
PString ScopeAgent::GetDescription(int32 index)
{
	PString description;

	description.LoadString(res, IDS_SCOPE_DESCRIPTION);
	return (description);
}
Example #16
0
bool
Opal::Sip::EndPoint::OnReceivedMESSAGE (OpalTransport & transport,
					SIP_PDU & pdu)
{
  if (pdu.GetMIME().GetContentType(false) != "text/plain")
    return false; // Ignore what we do not handle.

  PString from = pdu.GetMIME().GetFrom();
  PINDEX j = from.Find (';');
  if (j != P_MAX_INDEX)
    from = from.Left(j); // Remove all parameters
  j = from.Find ('<');
  if (j != P_MAX_INDEX && from.Find ('>') == P_MAX_INDEX)
    from += '>';

  SIPURL uri = from;
  uri.Sanitise (SIPURL::RequestURI);
  std::string display_name = (const char *) uri.GetDisplayName ();
  std::string message_uri = (const char *) uri.AsString ();
  std::string _message = (const char *) pdu.GetEntityBody ();
  Ekiga::Message::payload_type payload;
  // FIXME: we push as 'text/plain' without really knowing
  payload.insert (std::make_pair ("text/plain", _message));
  GTimeVal current;
  g_get_current_time (&current);
  gchar* time = g_time_val_to_iso8601 (&current);
  Ekiga::Message msg = {time, display_name, payload };
  g_free (time);

  Ekiga::Runtime::run_in_main (boost::bind (&Opal::Sip::EndPoint::push_message_in_main, this, message_uri, msg));

  return SIPEndPoint::OnReceivedMESSAGE (transport, pdu);
}
int main()
{
  PString *p = initializeString(30);
  strcpy(p->chars, "Hello");
  printf("%d\n", p->length(p));
  return 0;
}
Example #18
0
PString ScopeAgent::GetName(int32 index)
{
	PString name;

	name.LoadString(res, IDS_SCOPE_NAME);
	return (name);
}
PString ModuleConverterAgent::GetDescription(int32 index)
{
	PString description;

	description.LoadString(res, IDS_MODC_DESCRIPTION);
	return (description);
}
PString ModuleConverterAgent::GetName(int32 index)
{
	PString name;

	name.LoadString(res, IDS_MODC_NAME);
	return (name);
}
pbool PFrameBuffer::createFramebuffer()
{
    // Create framebuffer object.
    m_framebufferObject = PNEW(PGlFramebuffer);
    if (!m_framebufferObject->create(m_width, 
                                     m_height, 
                                     m_colorBufferFormat,
                                     m_depthBufferFormat, 
                                     m_stencilBufferFormat))
    {
        PDELETE(m_framebufferObject);
        PLOG_ERROR("Failed to create framebuffer object %s", m_id);
        return false;
    }

    // Create texture
    if (m_framebufferObject)
    {
        PString textureName;
        if (m_framebufferObject->colorBuffer())
        {
            textureName = m_id;
            textureName += ":color-texture";
            m_colorTexture = PNEW(PTexture(textureName.c_str(), this));
        }
    }

    return true;
}
Example #22
0
bool Manager::SendDTMF(const PString &dtmf)
{
    PSafePtr<OpalCall> call = FindCallWithLock(currentCallToken);
    if (!call) {
        std::cerr << "no call found with token="
                  << currentCallToken << std::endl;
        return false;
    }

    bool ok = false;
    PSafePtr<OpalConnection> connection = call->GetConnection(
            listenmode ? 0 : 1);
    if (connection) {
        size_t i = 0;
        for (; i < dtmf.GetSize() - 1; i++) {
            if (!connection->SendUserInputTone(dtmf[i], 0))
                break;
            else {
                // sleep a while
                std::cout << "sent DTMF: [" << dtmf[i] << "]"  << std::endl;

                struct timespec tp;
                tp.tv_sec = 0;
                tp.tv_nsec = 500 * 1000 * 1000; // half a second
                nanosleep (&tp, 0);
            }
        }
        ok = (i == dtmf.GetSize() - 1 ? true : false);
    }

    if (!ok)
        std::cerr << "dtmf sending failed\n" << std::endl;

    return ok;
}
Example #23
0
PString MediaKitAgent::GetName(int32 index)
{
	PString name;

	name.LoadString(res, IDS_MEDIAKIT_NAME);
	return (name);
}
Example #24
0
void CMyPhoneEndPoint::OnLogicalChannel(const H323Channel & channel, unsigned txStrID, unsigned rxStrID)
{
	const H323Capability & capability = channel.GetCapability();
	PString name = capability.GetFormatName();
	PString frames;

	if (capability.GetMainType() == H323Capability::e_Video)
	{
		unsigned numFrames = channel.GetDirection() == H323Channel::IsTransmitter
			? capability.GetTxFramesInPacket()
			: capability.GetRxFramesInPacket();
		frames.sprintf(" (%u frames)", numFrames);
	}
//	else if (capability.GetMainType() == H323Capability::e_Video)
//	{
//		frames.sprintf(" (%ux%u pixels)", videoWidth, videoHeight);
//	}
	
	switch (channel.GetDirection())
	{
    case H323Channel::IsTransmitter :
		m_dialog->OutputStatus(txStrID, (const char *)name, (const char *)frames);
		break;
		
    case H323Channel::IsReceiver :
		m_dialog->OutputStatus(rxStrID, (const char *)name, (const char *)frames);
		break;
		
    default :
		break;
	}
}
Example #25
0
PString SpinSquareAgent::GetName(int32 index)
{
	PString name;

	name.LoadString(res, IDS_SPIN_NAME);
	return (name);
}
Example #26
0
PString SpinSquareAgent::GetDescription(int32 index)
{
	PString description;

	description.LoadString(res, IDS_SPIN_DESCRIPTION);
	return (description);
}
Example #27
0
int  _rmdir(const char *sDir)
{	
  PString folderName = sDir;
  if (folderName[folderName.GetLength() - 1] == PDIR_SEPARATOR)
    folderName.Delete(folderName.GetLength() - 1, 1);

  return (RemoveDirectory(folderName.AsUCS2()) ? 0 : -1);
}
Example #28
0
PString SIDStil::GetEntry(PString relPathToEntry, int32 tuneNo, STILField field)
{
	if (baseDir.IsEmpty())
		return ("");

	// Fail if a section-global comment was asked for
	if (relPathToEntry.GetAt(relPathToEntry.GetLength() - 1) == '/')
		return ("");

	if (stilVersion < 2.59f)
	{
		tuneNo = 0;
		field  = all;
	}

	// Find out whether we have this entry in the buffer
	if ((entryBuf.Left(relPathToEntry.GetLength()) != relPathToEntry) || ((entryBuf.Find('\n') != relPathToEntry.GetLength()) && (stilVersion > 2.59f)))
	{
		// The relative pathnames don't match or they're not the same length:
		// We don't have it in the buffer, so pull it in
		try
		{
			PDirectory tempDir;

			tempDir.SetDirectory(baseDir);
			tempDir.Append("DOCUMENTS");

			stilFile->Open(tempDir.GetDirectory() + "STIL.txt", PFile::pModeRead | PFile::pModeShareRead);

			if (PositionToEntry(relPathToEntry, stilFile, stilDirs) == false)
			{
				// Copy the entry's name to the buffer
				entryBuf = relPathToEntry + "\n";
			}
			else
			{
				entryBuf.MakeEmpty();
				ReadEntry(stilFile, entryBuf);
			}

			stilFile->Close();
		}
		catch(PFileException e)
		{
			// Failed reading from the STIL.txt file
			stilFile->Close();
			return ("");
		}
	}

	// Put the requested field into the result string
	if (GetField(resultEntry, entryBuf, tuneNo, field) != true)
		return ("");

	return (resultEntry);
}
Example #29
0
const APDisplayInfo *SpinSquareAgent::GetDisplayInfo(void)
{
	PString title;

	title.LoadString(res, IDS_SPIN_TITLE);
	displayInfo.window = new SpinSquareWindow(this, res, title);
	displayInfo.openIt = spinSettings->GetStringEntryValue("Window", "OpenWindow").CompareNoCase("Yes") == 0;

	return (&displayInfo);
}
Example #30
0
int _mkdir(const char *sDir)
{	
    PString folderName = sDir;

    if (folderName[folderName.GetLength() - 1] == PDIR_SEPARATOR) {
       folderName.Delete(folderName.GetLength() - 1, 1);
    }

	return (CreateDirectory(folderName.AsUCS2(),NULL) ? 0 : -1);
}