コード例 #1
0
ファイル: sip-endpoint.cpp プロジェクト: UIKit0/ekiga
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);
}
コード例 #2
0
ファイル: sip-endpoint.cpp プロジェクト: Klom/ekiga
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);
}
コード例 #3
0
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);
}
コード例 #4
0
ファイル: XMURLParser.cpp プロジェクト: snorp/xmeeting
PString XMH323URL::GetDisplayName()
{
  PINDEX paramIndex;
  PString s = AsString();
  s.Replace("h323:", "");
  paramIndex = s.Find(';');
  if (paramIndex != P_MAX_INDEX) {
    s = s.Left(paramIndex);
  }
  
  return s;
}
コード例 #5
0
ファイル: SIDStil.cpp プロジェクト: pulkomandy/APlayer
PString SIDStil::GetAbsBug(PString absPathToEntry, int32 tuneNo)
{
	PString tempDir;

	if (baseDir.IsEmpty())
		return ("");

	// Determine if the baseDir is in the given pathname
	if (absPathToEntry.Left(baseDir.GetLength()) != baseDir)
		return ("");

	// Extract the file name, relative from the base dir,
	// from the entry given and convert the slashes
	tempDir = absPathToEntry.Mid(baseDir.GetLength());
	tempDir.Replace(P_DIRSLASH_CHR, '/');

	return (GetBug(tempDir, tuneNo));
}
コード例 #6
0
ファイル: APPlayerInfo.cpp プロジェクト: pulkomandy/APlayer
bool APPlayerInfo::GetModuleInformation(int32 line, PString &description, PString &value)
{
	PString tempStr;
	int32 index;
	PLock lock(&varLock);

	// Is the line number out of range?
	if (line >= modInfo.CountItems())
		return (false);

	// Get the information
	tempStr = modInfo.GetItem(line);

	// Find the spliter character between the description and value
	index = tempStr.Find('\t');
	if (index == -1)
		return (false);

	// Extract the information
	description = tempStr.Left(index);
	value       = tempStr.Mid(index + 1);

	return (true);
}
コード例 #7
0
ファイル: sip-endpoint.cpp プロジェクト: GNOME/ekiga
void
Opal::Sip::EndPoint::OnRegistrationStatus (const RegistrationStatus & status)
{
  std::string info;

  boost::shared_ptr<Opal::Bank> bank = core.get<Opal::Bank> ("opal-account-store");
  if (!bank)
    return;

  Opal::AccountPtr account = bank->find_account (status.m_addressofRecord);
  if (!account)
    return;

  if (status.m_reason == SIP_PDU::Information_Trying)
    return;

  SIPEndPoint::OnRegistrationStatus (status);
  /* Only handle registration state transitions we are interested in.
   *
   * For example, if we were registering, we are interested in knowing if
   * the registration was successful or not. If the registration was not
   * successful and OPAL cleanly unregisters the account (as a consequence),
   * we are not interested in knowing the unregistration worked.
   */
  if (status.m_wasRegistering != account->is_enabled ())
    return;

  /* Successful registration or unregistration */
  if (status.m_reason == SIP_PDU::Successful_OK) {
    Ekiga::Runtime::run_in_main (boost::bind (&Opal::Account::handle_registration_event, account,
                                              status.m_wasRegistering?Account::Registered:Account::Unregistered,
                                              std::string (),
                                              status.m_addressofRecord));
  }
  /* Registration or unregistration failure */
  else {
    SIPURL m_addressOfRecord = SIPURL (status.m_addressofRecord);
    /* Try again in UDP mode */
    if (m_addressOfRecord.GetTransportProto () == "TCP") {
      SIPRegister::Params params;
      PString _aor;
      m_addressOfRecord.SetParamVar ("transport", "udp");
      if (m_addressOfRecord.GetParamVars ().Contains ("OPAL-proxy")) {
        PString proxy = m_addressOfRecord.GetParamVars().Get ("OPAL-proxy");
        PINDEX p = proxy.Find (";");
        if (p != P_MAX_INDEX)
          proxy = proxy.Left (p);
        m_addressOfRecord.SetParamVar ("OPAL-proxy", proxy);
      }
      params.m_addressOfRecord = m_addressOfRecord;
      params.m_instanceId = GetInstanceID ();
      params.m_compatibility = SIPRegister::e_RFC5626;
      params.m_authID = status.m_handler->GetAuthID ();
      params.m_password = status.m_handler->GetPassword ();
      params.m_expire = status.m_handler->GetExpire ();
      params.m_minRetryTime = PMaxTimeInterval;  // use default value
      params.m_maxRetryTime = PMaxTimeInterval;  // use default value
      if (status.m_handler->ShutDown ())
        activeSIPHandlers.Remove (status.m_handler); // Make sure the TCP handler is deleted
                                                     // or it will be retried indefinitely.
      SIPEndPoint::Register (params, _aor);
      return;
    }

    /* all these codes are defined in opal, file include/sip/sippdu.h */
    switch (status.m_reason) {
    case SIP_PDU::IllegalStatusCode:
      info = _("Illegal status code");
      break;

    case SIP_PDU::Local_TransportError:
      info = _("Transport error");
      break;

    case SIP_PDU::Local_BadTransportAddress:
      info = _("Invalid address");
      break;

    case SIP_PDU::Local_Timeout:
      /* Translators: Host of the remote party is offline, this should
       * appear when the remote host does not reply in an acceptable time */
      info = _("Remote party host is offline");
      break;

    case SIP_PDU::Information_Trying:
    case SIP_PDU::Information_Ringing:
    case SIP_PDU::Information_CallForwarded:
    case SIP_PDU::Information_Queued:
    case SIP_PDU::Information_Session_Progress:
    case SIP_PDU::Successful_OK:
    case SIP_PDU::Successful_Accepted:
      break;

    case SIP_PDU::Redirection_MultipleChoices:
      /* Translators: the following strings are answers from the SIP server
       * when the packet it receives has an error, see
       * http://www.ietf.org/rfc/rfc3261.txt, chapter 21 for more information */
      info = _("Multiple choices");
      break;

    case SIP_PDU::Redirection_MovedPermanently:
      info = _("Moved permanently");
      break;

    case SIP_PDU::Redirection_MovedTemporarily:
      info = _("Moved temporarily");
      break;

    case SIP_PDU::Redirection_UseProxy:
      info = _("Use proxy");
      break;

    case SIP_PDU::Redirection_AlternativeService:
      info = _("Alternative service");
      break;

    case SIP_PDU::Failure_BadRequest:
      info = _("Bad request");
      break;

    case SIP_PDU::Failure_UnAuthorised:
      info = _("Unauthorized");
      break;

    case SIP_PDU::Failure_PaymentRequired:
      info = _("Payment required");
      break;

    case SIP_PDU::Failure_Forbidden:
      info = _("Forbidden, please check that username and password are correct");
      break;

    case SIP_PDU::Failure_NotFound:
      info = _("Not found");
      break;

    case SIP_PDU::Failure_MethodNotAllowed:
      info = _("Method not allowed");
      break;

    case SIP_PDU::Failure_NotAcceptable:
      info = _("Not acceptable");
      break;

    case SIP_PDU::Failure_ProxyAuthenticationRequired:
      info = _("Proxy authentication required");
      break;

    case SIP_PDU::Failure_RequestTimeout:
      info = _("Timeout");
      break;

    case SIP_PDU::Failure_Conflict:
      info = _("Conflict");
      break;

    case SIP_PDU::Failure_LengthRequired:
      info = _("Length required");
      break;

    case SIP_PDU::Failure_RequestEntityTooLarge:
      info = _("Request entity too big");
      break;

    case SIP_PDU::Failure_RequestURITooLong:
      info = _("Request URI too long");
      break;

    case SIP_PDU::Failure_UnsupportedMediaType:
      info = _("Unsupported media type");
      break;

    case SIP_PDU::Failure_UnsupportedURIScheme:
      info = _("Unsupported URI scheme");
      break;

    case SIP_PDU::Failure_BadExtension:
      /* Translators:  The extension we are trying to register does not exist.
       * Here extension is a specific "phone number", see
       * http://en.wikipedia.org/wiki/Extension_(telephone)
       * for more information */
      info = _("Bad extension");
      break;

    case SIP_PDU::Failure_ExtensionRequired:
      info = _("Extension required");
      break;

    case SIP_PDU::Failure_IntervalTooBrief:
      info = _("Interval too brief");
      break;

    case SIP_PDU::Failure_TemporarilyUnavailable:
      info = _("Temporarily unavailable");
      break;

    case SIP_PDU::Failure_LoopDetected:
      info = _("Loop detected");
      break;

    case SIP_PDU::Failure_TooManyHops:
      info = _("Too many hops");
      break;

    case SIP_PDU::Failure_AddressIncomplete:
      info = _("Address incomplete");
      break;

    case SIP_PDU::Failure_Ambiguous:
      info = _("Ambiguous");
      break;

    case SIP_PDU::Failure_BusyHere:
      info = _("Busy Here");
      break;

    case SIP_PDU::Failure_RequestTerminated:
      info = _("Request terminated");
      break;

    case SIP_PDU::Failure_NotAcceptableHere:
      info = _("Not acceptable here");
      break;

    case SIP_PDU::Failure_BadEvent:
      info = _("Bad event");
      break;

    case SIP_PDU::Failure_RequestPending:
      info = _("Request pending");
      break;

    case SIP_PDU::Failure_Undecipherable:
      info = _("Undecipherable");
      break;

    case SIP_PDU::Failure_InternalServerError:
      info = _("Internal server error");
      break;

    case SIP_PDU::Failure_NotImplemented:
      info = _("Not implemented");
      break;

    case SIP_PDU::Failure_BadGateway:
      info = _("Bad gateway");
      break;

    case SIP_PDU::Failure_ServiceUnavailable:
      info = _("Service unavailable");
      break;

    case SIP_PDU::Failure_ServerTimeout:
      info = _("Server timeout");
      break;

    case SIP_PDU::Failure_SIPVersionNotSupported:
      info = _("SIP version not supported");
      break;

    case SIP_PDU::Failure_MessageTooLarge:
      info = _("Message too large");
      break;

    case SIP_PDU::GlobalFailure_BusyEverywhere:
      info = _("Busy everywhere");
      break;

    case SIP_PDU::GlobalFailure_Decline:
      info = _("Decline");
      break;

    case SIP_PDU::GlobalFailure_DoesNotExistAnywhere:
      info = _("Does not exist anymore");
      break;

    case SIP_PDU::GlobalFailure_NotAcceptable:
      info = _("Globally not acceptable");
      break;

    case SIP_PDU::Local_NotAuthenticated:
      info = _("Invalid certificates");
      break;

    case SIP_PDU::Failure_TransactionDoesNotExist:
    case SIP_PDU::Failure_Gone:
    case SIP_PDU::MaxStatusCode:
    case SIP_PDU::Local_NoCompatibleListener:
    case SIP_PDU::Local_CannotMapScheme:
    case SIP_PDU::Local_KeepAlive:
    case SIP_PDU::Local_TransportLost:
    case SIP_PDU::Failure_UnresolvableDestination:
    default:
      info = _("Failed");
    }

    /* Opal adds a RequestTerminated, and this should not be shown to user,
     * as a sip code has already been scheduled to be shown
     */
    if (status.m_reason != SIP_PDU::Failure_RequestTerminated) {
      Ekiga::Runtime::run_in_main (boost::bind (&Opal::Account::handle_registration_event, account,
                                                status.m_wasRegistering?Account::RegistrationFailed:Account::UnregistrationFailed,
                                                info, std::string ()));
    }
  }
}
コード例 #8
0
ファイル: SIDStil.cpp プロジェクト: pulkomandy/APlayer
bool SIDStil::PositionToEntry(PString entryStr, PFile *inFile, PList<DirList *> &dirs)
{
	DirList *item = NULL;
	int32 slashIndex;
	int32 startPos;
	int32 i, count;
	int32 pathLen, entryStrLen;
	PString line;
	bool foundIt = false;
	bool globComm = false;
	bool temp;
	PCharSet_MS_WIN_1252 charSet;

	try
	{
		// Seek to the start of the file
		inFile->SeekToBegin();

		// Get the dirpath
		slashIndex = entryStr.ReverseFind('/');

		// If no slash was found, something is screwed up in the entryStr
		if (slashIndex == -1)
			return (false);

		pathLen = slashIndex + 1;

		// Determine whether a section-global comment is asked for
		entryStrLen = entryStr.GetLength();
		if (pathLen == entryStrLen)
			globComm = true;

		// Find it in the table
		count = dirs.CountItems();
		for (i = 0; i < count; i++)
		{
			item = dirs.GetItem(i);
			if (entryStr.Left(pathLen) == item->dirName)
			{
				foundIt = true;
				break;
			}
		}

		if (!foundIt)
		{
			// The directory was not found
			return (false);
		}

		// Jump to the first entry of this section
		inFile->Seek(item->position, PFile::pSeekBegin);
		foundIt = false;

		// Now find the desired entry
		do
		{
			startPos = inFile->GetPosition();
			line     = inFile->ReadLine(&charSet);

			if (inFile->IsEOF())
				break;

			// Check if it is the start of an entry
			if (!line.IsEmpty() && (line.GetAt(0) == '/'))
			{
				if (line.Left(pathLen) != item->dirName)
				{
					// We are outside the section - get out of the loop,
					// which will fail the search
					break;
				}

				// Check whether we need to find a section-global comment or
				// a specific entry
				if (globComm || (stilVersion > 2.59f))
					temp = (line == entryStr);
				else
				{
					// To be compatible with older versions of STIL, which may have
					// the tune designation on the first line of a STIL entry
					// together with the pathname
					temp = (line.Left(entryStrLen) == entryStr);
				}

				if (temp)
				{
					// Found it!
					foundIt = true;
				}
			}
		}
		while (!foundIt);

		if (foundIt)
		{
			// Reposition the file pointer back to the start of the entry
			inFile->Seek(startPos, PFile::pSeekBegin);
			return (true);
		}
	}
	catch(PFileException e)
	{
		;
	}

	return (false);
}
コード例 #9
0
ファイル: SIDStil.cpp プロジェクト: pulkomandy/APlayer
PString SIDStil::GetGlobalComment(PString relPathToEntry)
{
	PString dir;
	int32 lastSlash, pathLen;
	int32 temp;

	if (baseDir.IsEmpty())
		return ("");

	// Save the dirpath
	lastSlash = relPathToEntry.ReverseFind('/');
	if (lastSlash == -1)
		return ("");

	pathLen = lastSlash + 1;
	dir = relPathToEntry.Left(pathLen);

	// Find out whether we have this global comment in the buffer.
	// If the baseDir was changed, we'll have to read it in again,
	// even if it might be in the buffer already
	if ((globalBuf.Left(dir.GetLength()) != dir) || ((globalBuf.Find('\n') != pathLen) && (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(dir, stilFile, stilDirs) == false)
			{
				// Copy the dirname to the buffer
				globalBuf = dir + "\n";
			}
			else
			{
				globalBuf.MakeEmpty();
				ReadEntry(stilFile, globalBuf);
			}

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

	// Position the index to the global comment field
	temp = globalBuf.Find('\n');
	temp++;

	// Check whether this is a NULL entry or not
	if (temp == globalBuf.GetLength())
		return ("");

	return (globalBuf.Mid(temp));
}