void MsgRecordForm::OnFinalMessage( HWND hWnd )
{
    std::string play_sid = AudioCallback::GetPlaySid();
    std::wstring wsid = nbase::UTF8ToUTF16(play_sid);
    if(GetWindowId() == wsid)
    {
        AudioCallback::SetPlaySid("");
        AudioCallback::SetPlayCid("");

        nim_audio::Audio::StopPlayAudio();
    }
    __super::OnFinalMessage(hWnd);
}
void MsgRecordForm::RefreshRecord(std::string id, nim::NIMSessionType type)
{
	if(id == session_id_)
		return;
	session_id_ = id;
	session_type_ = type;

	//初始化
	first_show_msg_ = true;
	last_msg_time_ = 0;
	farst_msg_time_ = 0;
	last_server_id_ = 0;

	has_more_ = true;
	is_loading_ = false;

	std::wstring name;
	if (type == nim::kNIMSessionTypeP2P)
		name = UserService::GetInstance()->GetUserName(id);
	else
		name = TeamService::GetInstance()->GetTeamName(id);
	label_title_->SetText(name);
	SetTaskbarTitle(name);

	msg_list_->RemoveAll();
	id_bubble_pair_.clear();

	std::string play_sid = AudioCallback::GetPlaySid();
	std::wstring wsid = nbase::UTF8ToUTF16(play_sid);
	if(GetWindowId() == wsid)
	{
		AudioCallback::SetPlaySid("");
		AudioCallback::SetPlayCid("");

		nim_audio::Audio::StopPlayAudio();
	}

	if (type == nim::kNIMSessionTypeTeam)
	{
		nim::Team::QueryTeamMembersCallback cb = ToWeakCallback([this](const std::string& tid, int member_count, const std::list<nim::TeamMemberProperty>& props) 
		{
			team_member_info_list_.clear();
			for (const auto &info : props)
				team_member_info_list_[info.GetAccountID()] = info;
			ShowMore(false);
		});
		nim::Team::QueryTeamMembersAsync(session_id_, cb);
	}
	else
		ShowMore(false);
}
Exemple #3
0
int CAppManager::CreateWindowId(const CStdString& strAppId, int iWindowId)
{
  int windowId = GetWindowId(strAppId, iWindowId);
  if (windowId != WINDOW_INVALID)
  {
    return windowId;
  }

  m_iWindowIdCounter++;
  std::map<int,int> windowMap;
  windowMap[iWindowId] = m_iWindowIdCounter;
  m_mapAppWindows[strAppId] = windowMap;

  return m_iWindowIdCounter;
}
Exemple #4
0
void CAppManager::LaunchSkinApp(const CAppDescriptor& desc, const CStdString& urlStr, bool isNative)
{
  CLog::Log(LOGDEBUG, "CAppManager::LaunchSkinApp, id = %s, url = %s (applaunch), isNative = %d", desc.GetId().c_str(), urlStr.c_str(), isNative);

  /*
   * Load all the skin files
   */
  CURI url(urlStr);
  if (desc.GetId() != m_lastLaunchedAppId)
  {
    if (isNative && m_nativeApp == NULL)
    {
      CStdString path = desc.GetLocalPath();
      CStdString appPath;

    #ifdef __APPLE__
      CUtil::AddFileToFolder(path, "boxeeapp-x86-osx.so", appPath);
    #elif defined (CANMORE)
      CUtil::AddFileToFolder(path, "boxeeapp-i686-cm-linux.so", appPath);
    #elif defined (_LINUX) && defined (__x86_64__)
      CUtil::AddFileToFolder(path, "boxeeapp-x86_64-linux.so", appPath);
    #elif defined (_LINUX)
      CUtil::AddFileToFolder(path, "boxeeapp-x86-linux.so", appPath);
    #else
      CUtil::AddFileToFolder(path, "boxeeapp.dll", appPath);
    #endif

#ifdef HAS_EMBEDDED
      if (!CUtil::CheckFileSignature(appPath, desc.GetSignature()))
      {
        CLog::Log(LOGERROR,"application can not be verified. aborting.");
        return;
      }
#endif
      
      // Unload previous libs
      for (size_t i = 0; i < m_sharedLibs.size(); i++)
      {
        m_sharedLibs[i]->Unload();
        delete m_sharedLibs[i];
      }
      m_sharedLibs.clear();

      const std::vector<CStdString>& libs = desc.GetAdditionalSharedLibraries();
      for (size_t i = 0; i < libs.size(); i++)
      {
        CStdString libPath;
        CUtil::AddFileToFolder(path, libs[i], libPath);

        LibraryLoader* lib = DllLoaderContainer::LoadModule(libPath);
        if (!lib)
        {
          CLog::Log(LOGERROR, "NativeApp::Launch: could not load additional app dll: %s", libPath.c_str());
          return;
        }

        m_sharedLibs.push_back(lib);
      }

      m_dll.SetFile(appPath);
      m_dll.EnableDelayedUnload(false);

      if (!m_dll.Load())
      {
        CLog::Log(LOGERROR, "NativeApp::Launch: could not load app dll");
        return;
      }

      if (!m_dll.xapp_initialize(&m_nativeApp))
      {
        CLog::Log(LOGERROR, "NativeApp::Launch: could not initialize app dll");
        return;
      }
      m_bNativeAppStarted = false;
    }

    CStdString mediaPath = desc.GetMediaPath();

    CStdString xmlFile = "";
    CStdString skinPath = desc.GetSkinPath(xmlFile);

    CFileItemList skinItems;
    DIRECTORY::CDirectory::GetDirectory(skinPath, skinItems);
    for (int i = 0; i < skinItems.Size(); i++)
    {
      CFileItemPtr pItem = skinItems[i];
      CLog::Log(LOGDEBUG, "Loading skin %s for app %s",  pItem->m_strPath.c_str(), desc.GetId().c_str());

      // Load the skin file to check it's a window and get the id
      TiXmlDocument xmlDoc;
      if (!xmlDoc.LoadFile(pItem->m_strPath))
      {
        CLog::Log(LOGERROR, "Unable to load skin file %s", pItem->m_strPath.c_str());
        continue;
      }

      TiXmlElement* rootElement = xmlDoc.RootElement();
      if (strcmpi(rootElement->Value(), "window") != 0)
      {
        CLog::Log(LOGERROR, "Invalid skin file %s. No window root element", pItem->m_strPath.c_str());
        continue;
      }

      const char* windowIdStr = rootElement->Attribute("id");
      if (!windowIdStr)
      {
        CLog::Log(LOGERROR, "Invalid skin file %s. No window id in root element", pItem->m_strPath.c_str());
        continue;
      }

      // Create a new window from the skin file
      int windowId = atoi(windowIdStr);

      // APPWINDOW: Translate window id to correct window
      int realWindowId = CreateWindowId(desc.GetId(), windowId);

      CLog::Log(LOGDEBUG, "Get window for id = %d, translated id = %d, app id = %s (applaunch)", windowId, realWindowId, desc.GetId().c_str());
      CGUIWindow* newWindow = g_windowManager.GetWindow(realWindowId);

      if (newWindow == NULL)
      {
        CLog::Log(LOGDEBUG, "Create new window for id = %d, translated id = %d, app id = %s (applaunch)", windowId, realWindowId, desc.GetId().c_str());
        if (rootElement->Attribute("type") && strcmp(rootElement->Attribute("type"), "dialog") == 0)
        {
          newWindow = new CGUIDialog(realWindowId, pItem->m_strPath);
        }
        else
        {
          newWindow = new CGUIWindowApp(realWindowId, pItem->m_strPath, desc);
        }

        // Add the custom window to the window manager
        g_windowManager.AddCustomWindow(newWindow);
      }
      else
      {
        CLog::Log(LOGDEBUG, "Found existing window for id = %d, translated id = %d, app id = %s (applaunch)", windowId, realWindowId, desc.GetId().c_str());
      }

      //      // If a window with the same id exists, delete it
      //      if (g_windowManager.GetWindow(realWindowId) != NULL)
      //      {
      //        // we can do this because this is for sure a window of this specific application
      //        g_windowManager.Delete(realWindowId);
      //      }

    }

    // Load the app strings      
    ClearPluginStrings();
    LoadPluginStrings(desc);

    // Load the registry of the application
    m_registry.Load(desc);

    // Clear all the parameters of the previous windows
    m_params.clear();

    // Remember the last running application
    m_lastLaunchedAppId = desc.GetId();
    m_lastLaunchedDescriptor = desc;
  }

  int windowId = 0;
  int realWindowId = 0;
  if (url.GetFileName() == "")
  {
    windowId = atoi(desc.GetStartWindow().c_str());
    realWindowId = GetWindowId(desc.GetId(), windowId);
    m_params[realWindowId].clear();
  }
  else
  {
    windowId = atoi(url.GetFileName().c_str());
    if (windowId != 0)
    {
      realWindowId = GetWindowId(desc.GetId(), windowId);
      m_params[realWindowId].clear();
      m_params[realWindowId] = url.GetOptionsAsMap();
      CLog::Log(LOGDEBUG, "Add params for window %d (applaunch)", windowId);
    }
    else
    {
      // I am not sure this is necessary but I put it here to preserve previous functionality
      m_params[windowId].clear();
      m_params[windowId] = url.GetOptionsAsMap();
    }
  }

  if (desc.IsTestApp())
  {
    // if TestApp -> remove its context
    //CloseAppJob* j = new CloseAppJob(desc.GetId());
    //g_application.getApplicationMessenger().ExecuteOnMainThread(j, false, true);
  }

  if (m_nativeApp && !m_bNativeAppStarted)
  {
    m_nativeApp->Start(0, NULL);
    m_bNativeAppStarted = true;
  }

  g_windowManager.CloseDialogs(true);

  if (windowId != 0)
  {
    // Activate the window of the application... we're good to go!
    CGUIWindowApp* pAppWindow = (CGUIWindowApp*) g_windowManager.GetWindow(realWindowId);
    if (pAppWindow) 
    {
      pAppWindow->ClearStateStack();
      g_windowManager.ActivateWindow(GetWindowId(desc.GetId(), windowId));
    }
    else
    {
      CLog::Log(LOGERROR, "Unable to retrieve window with id = %d", windowId);
    }
  }
  else if (!isNative)
  {
    CStdString python = desc.GetLocalPath();
    if (url.GetFileName().size() > 0)
      python = CUtil::AddFileToFolder(python, url.GetFileName());
    else
      python = CUtil::AddFileToFolder(python, desc.GetStartWindow());
    python += ".py";

    CStdString actualPython = python;
    if (!XFILE::CFile::Exists(actualPython))
    {
      actualPython = python;
      actualPython += "o";
      if (!XFILE::CFile::Exists(actualPython))
      {
        actualPython = python;
        actualPython += "c";
        if (!XFILE::CFile::Exists(actualPython))
        {
          CLog::Log(LOGERROR, "Cannot find pythong file (tried also pyc, pyo): %s (python)", python.c_str());
        }
      }
    }

    // Remove ? at the beginning of the options, if it exists
    CStdString options = url.GetOptions();
    if (options.Left(1) == "?")
    {
      options = options.Right(options.size() - 1);
    }

    const char* args[2];
    args[0] = python.c_str();
    args[1] = options.c_str();

    CLog::Log(LOGINFO, "Launch python file: %s (python)", python.c_str());
    CStdString strAppId = url.GetHostName();
    CLog::Log(LOGINFO, "Application id is: %s (python)", strAppId.c_str());
    g_pythonParser.evalFileInContext(actualPython, strAppId, desc.GetPartnerId(), 2, args);
  }
  else if (isNative)
  {
    // app://spotify/next?x=y&z=x
    if (url.GetFileName().size() > 0)
    {
      std::map<CStdString, CStdString> urlOptions = url.GetOptionsAsMap();
      std::map<std::string, std::string> options;

      std::map<CStdString, CStdString>::const_iterator itr;
      for(itr = urlOptions.begin(); itr != urlOptions.end(); ++itr)
      {
        std::string key = (*itr).first;
        std::string value = (*itr).second;

        options[key] = value;
      }
      m_nativeApp->Call(url.GetFileName(), options);
    }
  }
}
void MsgRecordForm::OnFinalMessage( HWND hWnd )
{
	AudioManager::GetInstance()->StopPlayAudio(nbase::UTF16ToUTF8(GetWindowId()));
	__super::OnFinalMessage(hWnd);
}
Exemple #6
0
Window*
DOM_BrowserTab::GetTabWindow()
{
	return g_windowManager->GetWindow(GetWindowId());
}