コード例 #1
0
ファイル: Js2nCtrl.cpp プロジェクト: xgc820313/js2n
PString FindPluginsPath( void )
{
	CRegString regStr( "CLSID\\{C802F39D-BF85-427A-A334-77E501DB62E9}\\InprocServer32\\", "", FALSE, HKEY_CLASSES_ROOT );

	string strRead			= regStr.read();
	PString strPluginPath	= strRead;
	PINDEX nPos				= strPluginPath.FindLast( "\\" );
	strPluginPath = strPluginPath.Mid( 0, nPos + 1 ) + "js2n\\";

	return strPluginPath;
}
コード例 #2
0
void 
Opal::Sip::EndPoint::OnPresenceInfoReceived (const PString & user,
                                             const PString & basic,
                                             const PString & note)
{
  PINDEX j;
  PCaselessString b = basic;
  PCaselessString s = note;

  std::string presence = "unknown";
  std::string status;

  if (!basic.IsEmpty () && !note.IsEmpty ()) {

    if (b.Find ("Open") != P_MAX_INDEX)
      presence = "online";
    else
      presence = "offline";
  
    if (s.Find ("Away") != P_MAX_INDEX)
      presence = "away";
    else if (s.Find ("On the phone") != P_MAX_INDEX
             || s.Find ("Ringing") != P_MAX_INDEX) 
      presence = "inacall";
    else if (s.Find ("dnd") != P_MAX_INDEX
             || s.Find ("Do Not Disturb") != P_MAX_INDEX) 
      presence = "dnd";
  
    else if (s.Find ("Free For Chat") != P_MAX_INDEX) 
      presence = "freeforchat";
  
    if ((j = s.Find (" - ")) != P_MAX_INDEX)
      status = (const char *) note.Mid (j + 3);
  }

  SIPURL sip_uri = SIPURL (user);
  sip_uri.Sanitise (SIPURL::ExternalURI);
  std::string _uri = sip_uri.AsString ();
  std::string old_presence = uri_presences[_uri].first;
  std::string old_status = uri_presences[_uri].second;
  
  // If first notification, and no information, then we are offline
  if (presence == "unknown" && old_presence.empty ())
    presence = "offline";

  // If presence change, then signal it to the various components
  // If presence is unknown (notification with empty body), and it is not the 
  // first notification, and we can conclude it is a ping back from the server 
  // to indicate the presence status did not change, hence we do nothing.
  if (presence != "unknown" && (old_presence != presence || old_status != status)) {
    uri_presences[_uri] = std::pair<std::string, std::string> (presence, status);
    runtime.run_in_main (sigc::bind (sigc::ptr_fun (presence_status_in_main), this, _uri, presence, status));
  }
}
コード例 #3
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));
}
コード例 #4
0
ファイル: plugin.cpp プロジェクト: xgc820313/js2n
NPBool CPlugin::init(NPWindow* pNPWindow)
{
  if(pNPWindow == NULL)
    return FALSE;

#ifdef XP_WIN
  m_hWnd = (HWND)pNPWindow->window;
  if(m_hWnd == NULL)
    return FALSE;

  // subclass window so we can intercept window messages and
  // do our drawing to it
  lpOldProc = SubclassWindow(m_hWnd, (WNDPROC)PluginWinProc);

  // associate window with our CPlugin object so we can access 
  // it in the window procedure
  SetWindowLong(m_hWnd, GWL_USERDATA, (LONG)this);
#endif

  m_Window = pNPWindow;

  m_bInitialized	= TRUE;
  g_pNPInstance		= m_pNPInstance;
  g_pNPWindow		= pNPWindow;
  PString strPluginPath;
#ifdef XP_WIN // NPAPI plugin
	//Get Current Path of exe
	char szFullFileName[ MAX_PATH ];
	GetModuleFileName ( GetModuleHandle(NULL), szFullFileName, MAX_PATH ) ;
	strPluginPath = szFullFileName;
	PINDEX nPos = strPluginPath.FindLast( "\\" );
	strPluginPath = strPluginPath.Mid( 0, nPos + 1 ) + "plugins\\js2n\\";
#else // not Windows - assuming Linux
    BrInitError error;
    if (br_init_lib(&error) == 0 && error != BR_INIT_ERROR_DISABLED)
    {
        printf( "Error - can't init binreloc, code %d\n", error );
    }
	strPluginPath = br_find_exe_dir("/usr/lib/firefox/plugins/");
	strPluginPath += "js2n/";
#endif
  g_NativeLogic.Init( g_strPageURL, strPluginPath );
  return TRUE;
}
コード例 #5
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);
}
コード例 #6
0
ファイル: SIDStil.cpp プロジェクト: pulkomandy/APlayer
bool SIDStil::GetField(PString &result, PString buffer, int32 tuneNo, STILField field)
{
	int32 start, firstTuneNo, temp, temp2 = -1;

	// Clean out the result buffer first
	result.MakeEmpty();

	// Position pointer to the first char beyond the file designation
	start = buffer.Find('\n');
	start++;

	// Check whether this is a NULL entry or not
	if (start == 0)
		return (false);

	// Is this a multitune entry?
	firstTuneNo = buffer.Find("(#", start);

	// This is a tune designation only if the previous char was
	// a newline (ie. if the "(#" is on the beginning of a line).
	if ((firstTuneNo >= 1) && (buffer.GetAt(firstTuneNo - 1) != '\n'))
		firstTuneNo = -1;

	if (firstTuneNo == -1)
	{
		//-------------------//
		// SINGLE TUNE ENTRY //
		//-------------------//
		//
		// Is the first thing in this STIL entry the COMMENT?
		temp = buffer.Find(_COMMENT_STR, start);

		// Search for other potential fields beyond the COMMENT
		if (temp == start)
		{
			temp2 = buffer.Find(_NAME_STR, start);
			if (temp2 == -1)
			{
				temp2 = buffer.Find(_AUTHOR_STR, start);
				if (temp2 == -1)
				{
					temp2 = buffer.Find(_TITLE_STR, start);
					if (temp2 == -1)
						temp2 = buffer.Find(_ARTIST_STR, start);
				}
			}
		}

		if (temp == start)
		{
			// Yes. So it's assumed to be a file-global comment
			if ((tuneNo == 0) && ((field == all) || ((field == comment) && (temp2 == -1))))
			{
				// Simply copy the stuff in
				result = buffer.Mid(start);
				return (true);
			}
			else if ((tuneNo == 0) && (field == comment))
			{
				// Just copy the comment
				result = buffer.Mid(start, temp2 - start);
				return (true);
			}
			else if ((tuneNo == 1) && (temp2 != -1))
			{
				// A specific field was asked for
				return (GetOneField(result, buffer.Mid(temp2), field));
			}
			else
			{
				// Anything else is invalid as of v2.00
				return (false);
			}
		}
		else
		{
			// No. Handle it as a regular entry
			if ((field == all) && ((tuneNo == 0) || (tuneNo == 1)))
			{
				// The complete entry was asked for. Simply copy the stuff in
				result = buffer.Mid(start);
				return (true);
			}
			else if (tuneNo == 1)
			{
				// A specific field was asked for
				return (GetOneField(result, buffer.Mid(start), field));
			}
			else
			{
				// Anything else is invalid as of v2.00
				return (false);
			}
		}
	}
	else
	{
		//-----------------//
		// MULTITUNE ENTRY //
		//-----------------//
		int32 myTuneNo, nextTuneNo;
		PString tuneNoStr;

		// Was the complete entry asked for?
		if (tuneNo == 0)
		{
			switch (field)
			{
				case all:
				{
					// Yes. Simply copy the stuff in
					result = buffer.Mid(start);
					return (true);
				}

				case comment:
				{
					// Only the file-global comment field was asked for
					if (firstTuneNo != start)
						return (GetOneField(result, buffer.Mid(start, firstTuneNo - start), comment));
					else
						return (false);
				}

				default:
				{
					// If a specific field other than a comment is
					// asked for tuneNo=0, this is illegal
					return (false);
				}
			}
		}

		// Search for the requested tune number
		tuneNoStr.Format("(#%d)", tuneNo);
		myTuneNo = buffer.Find(tuneNoStr, start);

		if (myTuneNo != -1)
		{
			// We found the requested tune number.
			// Set the pointer beyond it
			myTuneNo = buffer.Find('\n', myTuneNo) + 1;

			// Where is the next one?
			nextTuneNo = buffer.Find("\n(#", myTuneNo);
			if (nextTuneNo == -1)
			{
				// There is no next one - set pointer to the end of entry
				nextTuneNo = buffer.GetLength();
			}
			else
			{
				// The search included the \n - go beyond it
				nextTuneNo++;
			}

			// Put the desired fields into the result (which may be 'all')
			PString tempResult;
			bool retVal;

			retVal = GetOneField(tempResult, buffer.Mid(myTuneNo, nextTuneNo - myTuneNo), field);
			result += tempResult;
			return (retVal);
		}
		else
			return (false);
	}
}
コード例 #7
0
ファイル: SIDStil.cpp プロジェクト: pulkomandy/APlayer
bool SIDStil::GetOneField(PString &result, PString buffer, STILField field)
{
	int32 temp = -1;

	// Sanity check
	if (buffer.GetAt(buffer.GetLength() - 1) != '\n')
	{
		result.MakeEmpty();
		return (false);
	}

	switch (field)
	{
		case all:
			result += buffer;
			return (true);

		case name:
			temp = buffer.Find(_NAME_STR);
			break;

		case author:
			temp = buffer.Find(_AUTHOR_STR);
			break;

		case title:
			temp = buffer.Find(_TITLE_STR);
			break;

		case artist:
			temp = buffer.Find(_ARTIST_STR);
			break;

		case comment:
			temp = buffer.Find(_COMMENT_STR);
			break;

		default:
			break;
	}

	// If the field was not found or it is not in between 'start'
	// and 'end', it is declared a failure
	if (temp == -1)
	{
		result.MakeEmpty();
		return (false);
	}

	// Search for the end of this field. This is done by finding
	// where the next field starts
	int32 nextName, nextAuthor, nextTitle, nextArtist, nextComment, nextField;

	nextName    = buffer.Find(_NAME_STR, temp + 1);
	nextAuthor  = buffer.Find(_AUTHOR_STR, temp + 1);
	nextTitle   = buffer.Find(_TITLE_STR, temp + 1);
	nextArtist  = buffer.Find(_ARTIST_STR, temp + 1);
	nextComment = buffer.Find(_COMMENT_STR, temp + 1);

	// Now determine which one is the closest to our field - that one
	// will mark the end of the required field
	nextField = nextName;

	if (nextField == -1)
		nextField = nextAuthor;
	else if ((nextAuthor != -1) && (nextAuthor < nextField))
		nextField = nextAuthor;

	if (nextField == -1)
		nextField = nextTitle;
	else if ((nextTitle != -1) && (nextTitle < nextField))
		nextField = nextTitle;

	if (nextField == -1)
		nextField = nextArtist;
	else if ((nextArtist != -1) && (nextArtist < nextField))
		nextField = nextArtist;

	if (nextField == -1)
		nextField = nextComment;
	else if ((nextComment != -1) && (nextComment < nextField))
		nextField = nextComment;

	if (nextField == -1)
		nextField = buffer.GetLength();

	// Now nextField points to the last+1 char that should be copied to
	// result. Do that
	result += buffer.Mid(temp, nextField - temp);
	return (true);
}