本文整理汇总了C++中XAP_Frame::showMessageBox方法的典型用法代码示例。如果您正苦于以下问题:C++ XAP_Frame::showMessageBox方法的具体用法?C++ XAP_Frame::showMessageBox怎么用?C++ XAP_Frame::showMessageBox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XAP_Frame
的用法示例。
在下文中一共展示了XAP_Frame::showMessageBox方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: connect
ConnectResult XMPPAccountHandler::connect()
{
UT_DEBUGMSG(("XMPPAccountHandler::connect()\n"));
if (m_bLoggedIn)
return CONNECT_ALREADY_CONNECTED;
if (m_pConnection)
return CONNECT_IN_PROGRESS;
// try to request a frame here; note that this might return 0, for example on application startup
XAP_Frame *pFrame = XAP_App::getApp()->getLastFocussedFrame();
const std::string server = getProperty("server");
const std::string username = getProperty("username");
const std::string port = getProperty("port"); // TODO: unused atm
const std::string resource = getProperty("resource");
const std::string encryption = getProperty("encryption");
std::string jid = username + "@" + server;
UT_DEBUGMSG(("Connecting to server: |%s|, username: |%s|, resource: |%s|\n",
server.c_str(), username.c_str(), resource.c_str()));
// NULL means perform SRV record lookup based on JID (Loudmouth 1.3.2+)
m_pConnection = lm_connection_new(NULL);
UT_return_val_if_fail(m_pConnection, CONNECT_INTERNAL_ERROR);
lm_connection_set_jid(m_pConnection, jid.c_str());
// setup SSL
if (lm_ssl_is_supported() && encryption == "true")
{
LmSSL* pSSL = lm_ssl_new(NULL, NULL, NULL, NULL); // TODO: free this
lm_ssl_use_starttls(pSSL, TRUE, TRUE);
lm_connection_set_ssl(m_pConnection, pSSL);
lm_ssl_unref(pSSL);
}
GError* error = NULL;
if (!lm_connection_open(m_pConnection, lm_connection_open_async_cb, this, NULL, &error))
{
UT_DEBUGMSG(("Failed to open: %s\n", error ? error->message : ""));
lm_connection_unref(m_pConnection);
m_pConnection = NULL;
if (pFrame)
{
// inform the user of the connection failure
// TODO: this shouldn't be here, the caller should handle this
UT_UTF8String msg;
// TODO: make this localizable
UT_UTF8String_sprintf(msg, "Error while connecting to %s: %s\n", server.c_str(), (error ? error->message : ""));
pFrame->showMessageBox(msg.utf8_str(), XAP_Dialog_MessageBox::b_O, XAP_Dialog_MessageBox::a_OK);
}
return CONNECT_FAILED;
}
return CONNECT_IN_PROGRESS;
}
示例2: convert
bool GR_MathManager::convert(UT_uint32 iConType, UT_ByteBuf & From, UT_ByteBuf & To)
{
XAP_App * pApp = XAP_App::getApp();
XAP_Frame * pFrame = pApp->getLastFocussedFrame();
if (iConType != 0)
{
return false;
}
/* add a pair of enclosing brackets \[ \] */
UT_UTF8String sLatex;
UT_UCS4_mbtowc myWC;
sLatex += "\\[";
sLatex.appendBuf(From, myWC);
sLatex += "\\]";
char * mathml = itex2MML_parse(sLatex.utf8_str(), sLatex.size());
if (!mathml)
{
pFrame->showMessageBox("itex2MML failed to convert the LaTeX equation into MathML, sorry!\n", // TODO: fix message
XAP_Dialog_MessageBox::b_O,
XAP_Dialog_MessageBox::a_OK);
return false;
}
UT_UTF8String sMathML(mathml);
itex2MML_free_string(mathml);
if (sMathML.size() == 0)
{
UT_UTF8String sErrMessage = "itex2MML conversion from LaTex equation resulted in zero-length MathML!\n"; // TODO: fix message
//sErrMessage += sLatex;
sErrMessage += "\n";
// sErrMessage += FullLine;
pFrame->showMessageBox(sErrMessage.utf8_str(),
XAP_Dialog_MessageBox::b_O,
XAP_Dialog_MessageBox::a_OK);
return false;
}
UT_DEBUGMSG(("Input MathML %s \n", sMathML.utf8_str()));
return EntityTable().convert(sMathML.utf8_str(), sMathML.size(), To);
}
示例3: ShowErrorBox
void AP_Dialog_FormatTable::ShowErrorBox(UT_String & sFile, UT_Error errorCode)
{
XAP_String_Id String_id;
XAP_Frame * pFrame = XAP_App::getApp()->getLastFocussedFrame();
switch (errorCode)
{
case -301:
String_id = AP_STRING_ID_MSG_IE_FileNotFound;
break;
case -302:
String_id = AP_STRING_ID_MSG_IE_NoMemory;
break;
case -303:
String_id = AP_STRING_ID_MSG_IE_UnsupportedType;
//AP_STRING_ID_MSG_IE_UnknownType;
break;
case -304:
String_id = AP_STRING_ID_MSG_IE_BogusDocument;
break;
case -305:
String_id = AP_STRING_ID_MSG_IE_CouldNotOpen;
break;
case -306:
String_id = AP_STRING_ID_MSG_IE_CouldNotWrite;
break;
case -307:
String_id = AP_STRING_ID_MSG_IE_FakeType;
break;
case -311:
String_id = AP_STRING_ID_MSG_IE_UnsupportedType;
break;
default:
String_id = AP_STRING_ID_MSG_ImportError;
}
pFrame->showMessageBox(String_id,
XAP_Dialog_MessageBox::b_O,
XAP_Dialog_MessageBox::a_OK,
sFile.c_str());
}
示例4: removeBuddy
void AbiCollabSessionManager::removeBuddy(BuddyPtr pBuddy, bool graceful)
{
UT_return_if_fail(pBuddy);
UT_DEBUGMSG(("Dropping buddy '%s' from all sessions\n", pBuddy->getDescription().utf8_str()));
// TODO: should we send out events for every buddy we drop, or session
// we delete?
for (UT_sint32 i = m_vecSessions.getItemCount() - 1; i >= 0; i--)
{
AbiCollab* pSession = m_vecSessions.getNthItem(i);
UT_continue_if_fail(pSession);
if (pSession->isLocallyControlled())
{
pSession->removeCollaborator(pBuddy);
}
else
{
// we don't control this session, meaning we can drop it completely
// if this buddy controlled it
// TODO: when we allow more than 1 buddy in a non-locally controlled,
// then remove it from that list here
if (pSession->isController(pBuddy))
{
UT_DEBUGMSG(("This buddy controlled a session, destroying the session...\n"));
std::string docName = pSession->getDocument()->getFilename();
if (docName == "")
docName = "Untitled"; // TODO: fetch the title from the frame somehow (which frame?) - MARCM
destroySession(pSession);
if (!graceful)
{
XAP_Frame *pFrame = XAP_App::getApp()->getLastFocussedFrame();
UT_continue_if_fail(pFrame);
// TODO: make this localizable
UT_UTF8String msg;
UT_UTF8String_sprintf(msg, "You've been disconnected from buddy %s. The collaboration session for document %s has been stopped.", pBuddy->getDescription().utf8_str(), docName.c_str());
pFrame->showMessageBox(msg.utf8_str(), XAP_Dialog_MessageBox::b_O, XAP_Dialog_MessageBox::a_OK);
}
}
}
}
}
示例5: closeSession
void AbiCollabSessionManager::closeSession(AbiCollab* pSession, bool canConfirm)
{
UT_DEBUGMSG(("Stopping collaboration session %s\n", pSession->getSessionId().utf8_str()));
UT_return_if_fail(pSession);
// TODO: in the future, we should hand over control to someone
// else within this session first, if possible
// ask for confirmation if we are in control of this session, and people are connected to us,
if (pSession->isLocallyControlled() &&
pSession->getCollaborators().size() > 0 &&
canConfirm)
{
XAP_Frame *pFrame = XAP_App::getApp()->getLastFocussedFrame();
UT_return_if_fail(pFrame);
UT_UTF8String msg;
// TODO: make this localizable
UT_UTF8String_sprintf(msg, "This document is currently being shared with %u people. Are you sure you want to stop sharing this document?", pSession->getCollaborators().size());
if (pFrame->showMessageBox(msg.utf8_str(), XAP_Dialog_MessageBox::b_YN, XAP_Dialog_MessageBox::a_NO) != XAP_Dialog_MessageBox::a_YES)
return;
}
// check who is controlling this session
if (pSession->isLocallyControlled())
{
UT_UTF8String pDestroyedSession = pSession->getSessionId();
// kill the session
destroySession(pSession);
// notify all that this session is closed
CloseSessionEvent event(pDestroyedSession);
event.setBroadcast(true);
signal(event);
}
else
{
// we are joined to this session, so we aren't allowed to close it;
// we should disjoin it instead
UT_ASSERT(UT_NOT_REACHED);
}
}
示例6: authenticate
bool XMPPAccountHandler::authenticate()
{
UT_DEBUGMSG(("XMPPAccountHandler::authenticate()\n"));
UT_return_val_if_fail(m_pConnection, false);
// try to request a frame here; note that this might return 0, for example on application startup
XAP_Frame *pFrame = XAP_App::getApp()->getLastFocussedFrame();
const std::string server = getProperty("server");
const std::string username = getProperty("username");
const std::string password = getProperty("password");
const std::string resource = getProperty("resource");
GError* error = NULL;
if (!lm_connection_authenticate(m_pConnection, username.c_str(), password.c_str(),
resource.c_str(), lm_connection_authenticate_async_cb, this, NULL, &error))
{
UT_DEBUGMSG(("connect() - couldn't authenticate with '%s' '%s':\n%s\n",
username.c_str(), password.c_str(), (error ? error->message : "")));
lm_connection_close(m_pConnection, NULL);
lm_connection_unref(m_pConnection);
m_pConnection = NULL;
if (pFrame)
{
// inform the user of the authentication failure
// TODO: this shouldn't be here, the caller should handle this
UT_UTF8String msg;
// TODO: make this localizable
UT_UTF8String_sprintf(msg, "Error while connecting to %s: %s\n", server.c_str(), (error ? error->message : ""));
pFrame->showMessageBox(msg.utf8_str(), XAP_Dialog_MessageBox::b_O, XAP_Dialog_MessageBox::a_OK);
}
return false;
}
return true;
}
示例7: HIWORD
BOOL AP_Win32Dialog_Styles::_onCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
WORD wNotifyCode = HIWORD(wParam);
WORD wId = LOWORD(wParam);
HWND hWndCtrl = (HWND)lParam;
switch (wId)
{
case AP_RID_DIALOG_STYLES_TOP_BUTTON_APPLY:
{
const gchar * szStyle = getCurrentStyle();
if(szStyle && *szStyle)
{
getView()->setStyle(szStyle);
}
}
m_answer = a_OK;
return 1;
case AP_RID_DIALOG_STYLES_TOP_BUTTON_CLOSE:
case IDCANCEL:
m_answer = a_CANCEL;
EndDialog(hWnd,0);
return 1;
case IDOK:
{
const XAP_StringSet * pSS = m_pApp->getStringSet ();
WCHAR stylename[MAX_EBX_LENGTH+1];
// Verfiy a name value for the style
// TODO - Verify unique name value
GetDlgItemTextW(hWnd,AP_RID_DIALOG_STYLES_NEWMODIFY_EBX_NAME,stylename,MAX_EBX_LENGTH);
/*_win32DialogNewModify.getControlText( AP_RID_DIALOG_STYLES_NEWMODIFY_EBX_NAME,
m_newStyleName,
MAX_EBX_LENGTH );*/
UT_UTF8String str;
str.appendUCS2((const UT_UCS2Char*)stylename,0);
strcpy(m_newStyleName,str.utf8_str());
if( !m_newStyleName || !strlen(m_newStyleName) )
{
getFrame()->showMessageBox( pSS->getValue (AP_STRING_ID_DLG_Styles_ErrBlankName),
XAP_Dialog_MessageBox::b_O,
XAP_Dialog_MessageBox::a_OK);
return 1;
}
//strcpy (m_newStyleName, (AP_Win32App::s_fromWinLocaleToUTF8(m_newStyleName)).utf8_str());
}
m_answer = a_OK;
EndDialog(hWnd,0);
return 1;
case AP_RID_DIALOG_STYLES_TOP_COMBO_LIST:
if( wNotifyCode == CBN_SELCHANGE )
{
switch(_win32Dialog.getComboSelectedIndex(AP_RID_DIALOG_STYLES_TOP_COMBO_LIST))
{
case 0:
m_whichType = USED_STYLES;
break;
case 1:
m_whichType = ALL_STYLES;
break;
case 2:
m_whichType = USER_STYLES;
break;
}
_populateWindowData();
}
return 1;
case AP_RID_DIALOG_STYLES_TOP_LIST_STYLES:
if (wNotifyCode == LBN_SELCHANGE)
{
UT_uint32 nData = -1;
const char* name;
const PD_Style * pcStyle = NULL;
int row = _win32Dialog.getListSelectedIndex(AP_RID_DIALOG_STYLES_TOP_LIST_STYLES);
nData = _win32Dialog.getListDataItem( AP_RID_DIALOG_STYLES_TOP_LIST_STYLES, row);
if (row!=LB_ERR)
{
getDoc()->enumStyles(nData, &name, &pcStyle);
m_selectedStyle = name;
m_nSelectedStyleIdx = nData;
// refresh the previews
_populatePreviews(false);
}
//.........这里部分代码省略.........
示例8: GetDlgItem
//.........这里部分代码省略.........
result = SendDlgItemMessageW(hWnd, AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_TYPE, CB_FINDSTRING, -1,
(LPARAM) str.c_str());
_win32DialogNewModify.selectComboItem( AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_TYPE, result );
eventBasedOn();
eventFollowedBy();
eventStyleType();
fillVecFromCurrentPoint();
}
else
{
const char * szCurrentStyle = NULL;
const char * szBasedOn = NULL;
const char * szFollowedBy = NULL;
const char * pLocalised = NULL;
PD_Style * pStyle = NULL;
PD_Style * pBasedOnStyle = NULL;
PD_Style * pFollowedByStyle = NULL;
szCurrentStyle = m_selectedStyle.c_str();
pt_PieceTable::s_getLocalisedStyleName(szCurrentStyle, utf8);
pLocalised = utf8.utf8_str();
_win32DialogNewModify.setControlText( AP_RID_DIALOG_STYLES_NEWMODIFY_EBX_NAME,
pLocalised);
if(szCurrentStyle)
getDoc()->getStyle(szCurrentStyle,&pStyle);
if(!pStyle)
{
XAP_Frame * pFrame = getFrame();
pFrame->showMessageBox( pSS->getValue(AP_STRING_ID_DLG_Styles_ErrNoStyle),
XAP_Dialog_MessageBox::b_O,
XAP_Dialog_MessageBox::a_OK);
m_answer = AP_Dialog_Styles::a_CANCEL;
return false;
}
//
// Valid style get the Based On and followed by values
//
pBasedOnStyle = pStyle->getBasedOn();
pFollowedByStyle = pStyle->getFollowedBy();
size_t nStyles = getDoc()->getStyleCount();
const char * name = NULL;
const PD_Style * pcStyle = NULL;
UT_GenericVector<PD_Style*> * pStyles = NULL;
getDoc()->enumStyles(pStyles);
UT_return_val_if_fail( pStyles, FALSE );
for (UT_uint32 i = 0; i < nStyles; i++)
{
pcStyle = pStyles->getNthItem(i);
UT_return_val_if_fail( pcStyle, FALSE );
name = pcStyle->getName();
if(pBasedOnStyle && pcStyle == pBasedOnStyle)
{
szBasedOn = name;
}
if(pFollowedByStyle && pcStyle == pFollowedByStyle)
{
szFollowedBy = name;
}
示例9: openCmdLineFiles
AP_App::AP_App (HINSTANCE hInstance, const char * szAppName)
: XAP_App_BaseClass ( hInstance, szAppName )
#else
AP_App::AP_App (const char * szAppName)
: XAP_App_BaseClass ( szAppName )
#endif
{
}
AP_App::~AP_App ()
{
}
/*!
* Open windows requested on commandline.
*
* \return False if an unknown command line option was used, true
* otherwise.
*/
bool AP_App::openCmdLineFiles(const AP_Args * args)
{
int kWindowsOpened = 0;
const char *file = NULL;
if (AP_Args::m_sFiles == NULL) {
// no files to open, this is ok
XAP_Frame * pFrame = newFrame();
pFrame->loadDocument((const char *)NULL, IEFT_Unknown);
return true;
}
int i = 0;
while ((file = AP_Args::m_sFiles[i++]) != NULL) {
char * uri = NULL;
uri = UT_go_shell_arg_to_uri (file);
XAP_Frame * pFrame = newFrame();
UT_Error error = pFrame->loadDocument (uri, IEFT_Unknown, true);
g_free (uri);
if (UT_IS_IE_SUCCESS(error))
{
kWindowsOpened++;
if (error == UT_IE_TRY_RECOVER) {
pFrame->showMessageBox(AP_STRING_ID_MSG_OpenRecovered,
XAP_Dialog_MessageBox::b_O,
XAP_Dialog_MessageBox::a_OK);
}
}
else
{
// TODO we crash if we just delete this without putting something
// TODO in it, so let's go ahead and open an untitled document
// TODO for now. this would cause us to get 2 untitled documents
// TODO if the user gave us 2 bogus pathnames....
// Because of the incremental loader, we should not crash anymore;
// I've got other things to do now though.
kWindowsOpened++;
pFrame->loadDocument((const char *)NULL, IEFT_Unknown);
pFrame->raise();
errorMsgBadFile (pFrame, file, error);
}
if (args->m_sMerge) {
PD_Document * pDoc = static_cast<PD_Document*>(pFrame->getCurrentDoc());
pDoc->setMailMergeLink(args->m_sMerge);
}
}
if (kWindowsOpened == 0)
{
// no documents specified or openable, open an untitled one
XAP_Frame * pFrame = newFrame();
pFrame->loadDocument((const char *)NULL, IEFT_Unknown);
if (args->m_sMerge) {
PD_Document * pDoc = static_cast<PD_Document*>(pFrame->getCurrentDoc());
pDoc->setMailMergeLink(args->m_sMerge);
}
}
return true;
}
示例10: DECLARE_ABI_PLUGIN_METHOD
//
// AbiPaint editImage
// ------------------
// This is the function that we actually call to invoke the image editor.
//
// parameters are:
// AV_View* v
// EV_EditMethodCallData *d
//
static DECLARE_ABI_PLUGIN_METHOD(editImage)
{
UT_UNUSED(v);
// Get the current view that the user is in.
XAP_Frame *pFrame = XAP_App::getApp()->getLastFocussedFrame();
FV_View* pView = static_cast<FV_View*>(pFrame->getCurrentView());
//
// get values from preference (initial plugin execution should have set sensible defaults)
//
UT_String imageApp; // holds MAXPATH\appName <space> MAXPATH\imagefilename
bool bLeaveImageAsPNG;
// read stuff from the preference value
if (!prefsScheme->getValue(ABIPAINT_PREF_KEY_szProgramName, imageApp))
{
UT_ASSERT(UT_SHOULD_NOT_HAPPEN);
getDefaultApp(imageApp, bLeaveImageAsPNG);
}
// now that we have program name, try to get other flag (allows overriding default value)
// Note: we allow overriding, otherwise if we don't adhere to user's setting
// then the use BMP or not menu should be greyed to note it has no effect
prefsScheme->getValueBool(ABIPAINT_PREF_KEY_bLeaveImageAsPNG, &bLeaveImageAsPNG);
//
// generate a temp file name...
//
char *szTempFileName = NULL;
GError *err = NULL;
gint fp = g_file_open_tmp ("XXXXXX", &szTempFileName, &err);
if (err) {
g_warning ("%s", err->message);
g_error_free (err); err = NULL;
return FALSE;
}
close(fp);
UT_String szTmpPng = szTempFileName;
szTmpPng += ".png";
UT_String szTmp = szTmpPng; // default: our temp file is the created png file
PT_DocPosition pos = pView->saveSelectedImage((const char *)szTmpPng.c_str());
if(pos == 0)
{
remove(szTempFileName);
g_free (szTempFileName); szTempFileName = NULL;
pFrame->showMessageBox("You must select an Image before editing it", XAP_Dialog_MessageBox::b_O,XAP_Dialog_MessageBox::a_OK);
return false;
}
#ifdef ENABLE_BMP
//
// Convert png into bmp for best compatibility with Windows programs
// NOTE: probably looses detail/information though!!! so if possible use PNG
//
if (!bLeaveImageAsPNG)
{
szTmp = szTempFileName;
szTmp += ".bmp"; // our temp file is a bmp file
if (convertPNG2BMP(szTmpPng.c_str(), szTmp.c_str()))
{
pFrame->showMessageBox("Unable to convert PNG image data to BMP for external program use!", XAP_Dialog_MessageBox::b_O,XAP_Dialog_MessageBox::a_OK);
UT_ASSERT(UT_SHOULD_NOT_HAPPEN);
remove(szTempFileName);
g_free (szTempFileName); szTempFileName = NULL;
remove(szTmpPng.c_str());
return false;
}
// remove(szTmpPng.c_str());
}
#endif
// remove the temp file (that lacks proper extension)
remove(szTempFileName);
g_free (szTempFileName); szTempFileName = NULL;
//
// Get the initial file status.
//
struct stat myFileStat;
int ok = stat(szTmp.c_str(),&myFileStat);
if(ok < 0)
{
UT_ASSERT(UT_SHOULD_NOT_HAPPEN);
remove(szTmpPng.c_str());
remove(szTmp.c_str()); // should silently fail if exporting as PNG file
//.........这里部分代码省略.........
示例11: setup
bool XMPPAccountHandler::setup()
{
UT_DEBUGMSG(("XMPPAccountHandler::setup()\n"));
UT_return_val_if_fail(m_pConnection, false);
AbiCollabSessionManager* pManager = AbiCollabSessionManager::getManager();
UT_return_val_if_fail(pManager, false);
// try to request a frame here; note that this might return 0, for example on application startup
XAP_Frame *pFrame = XAP_App::getApp()->getLastFocussedFrame();
const std::string server = getProperty("server");
// Register message handler for presence messages
m_pPresenceHandler = lm_message_handler_new((LmHandleMessageFunction)presence_handler, reinterpret_cast< gpointer >(this), NULL);
lm_connection_register_message_handler(m_pConnection, m_pPresenceHandler, LM_MESSAGE_TYPE_PRESENCE, LM_HANDLER_PRIORITY_NORMAL);
// Register message handler for stream error messages
m_pStreamErrorHandler = lm_message_handler_new((LmHandleMessageFunction)stream_error_handler, reinterpret_cast< gpointer >(this), NULL);
lm_connection_register_message_handler(m_pConnection, m_pStreamErrorHandler, LM_MESSAGE_TYPE_STREAM_ERROR, LM_HANDLER_PRIORITY_NORMAL);
// Register message handler for chat messages
m_pChatHandler = lm_message_handler_new((LmHandleMessageFunction)chat_handler, reinterpret_cast< gpointer >(this), NULL);
lm_connection_register_message_handler(m_pConnection, m_pChatHandler, LM_MESSAGE_TYPE_MESSAGE, LM_HANDLER_PRIORITY_NORMAL);
// Send presence message to server
GError* error = NULL;
LmMessage* m = lm_message_new_with_sub_type(NULL, LM_MESSAGE_TYPE_PRESENCE, LM_MESSAGE_SUB_TYPE_NOT_SET);
if (!lm_connection_send(m_pConnection, m, &error))
{
UT_DEBUGMSG(("Presence message could not be sent: %s", error ? error->message : ""));
lm_connection_close(m_pConnection, NULL);
lm_connection_unref(m_pConnection);
m_pConnection = NULL;
// FIXME: unregister the message handlers!
// ...
if (pFrame)
{
// inform the user of the sending error
// TODO: this shouldn't be here, the caller should handle this
UT_UTF8String msg;
// TODO: make this localizable
UT_UTF8String_sprintf(msg, "Error while connecting to %s: %s\n", server.c_str(), (error ? error->message : ""));
pFrame->showMessageBox(msg.utf8_str(), XAP_Dialog_MessageBox::b_O, XAP_Dialog_MessageBox::a_OK);
}
return false;
}
lm_message_unref(m);
m_bLoggedIn = true;
// we are connected now, time to start sending out messages (such as events)
pManager->registerEventListener(this);
// signal all listeners we are logged in
AccountOnlineEvent event;
// TODO: fill the event
AbiCollabSessionManager::getManager()->signal(event);
return true;;
}
示例12: processPacket
//.........这里部分代码省略.........
// TODO: check this
}
// signal all
JoinSessionEvent event(joinedSessionId);
signal( event, buddy );
}
else
{
// we don't know this session, don't forward the packet
UT_ASSERT_HARMLESS(UT_NOT_REACHED);
}
return true;
}
case PCT_DisjoinSessionEvent:
{
DisjoinSessionEvent* dse = static_cast<DisjoinSessionEvent*>(packet);
const UT_UTF8String& disjoinedSessionId = dse->getSessionId();
// someone who joined this session disconnected, remove him from the collaboration session
AbiCollab* pSession = getSessionFromSessionId(disjoinedSessionId);
if (pSession)
{
pSession->removeCollaborator(buddy);
// signal all
DisjoinSessionEvent event(disjoinedSessionId);
signal(event, buddy);
}
else
{
// we don't know this session, don't forward the packet
UT_ASSERT_HARMLESS(UT_NOT_REACHED);
}
return true;
}
case PCT_CloseSessionEvent:
{
CloseSessionEvent* cse = static_cast<CloseSessionEvent*>(packet);
const UT_UTF8String& destroyedSessionId = cse->getSessionId();
buddy->destroyDocHandle( destroyedSessionId );
// handle the event outselves
AbiCollab* pSession = getSessionFromSessionId(destroyedSessionId);
if (pSession)
{
if (!isLocallyControlled(pSession->getDocument()))
{
std::string docName = pSession->getDocument()->getFilename();
if (docName == "")
docName = "Untitled"; // TODO: fetch the title from the frame somehow (which frame?) - MARCM
// the server hosting this session is gone, so let's disconnect as well
if (!destroySession(pSession))
{
UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN);
}
// signal all
CloseSessionEvent event( destroyedSessionId );
signal( event, buddy );
// inform the user of the disconnect
XAP_Frame *pFrame = XAP_App::getApp()->getLastFocussedFrame();
UT_return_val_if_fail(pFrame, true);
UT_UTF8String msg;
// TODO: make this localizable
UT_UTF8String_sprintf(msg, "Document %s is not being shared anymore by buddy %s. You are disconnected from the collaboration session.", docName.c_str(), buddy->getDescription().utf8_str());
pFrame->showMessageBox(msg.utf8_str(), XAP_Dialog_MessageBox::b_O, XAP_Dialog_MessageBox::a_OK);
}
else
{
// someone who is not controlling this session sends out messages he closed it!
// we will not forward this packet
UT_ASSERT_HARMLESS(UT_NOT_REACHED);
}
}
else
{
UT_DEBUGMSG(("Ignoring a CloseSession event for unknown session (%s)\n", destroyedSessionId.utf8_str()));
}
return true;
}
case PCT_AccountAddBuddyRequestEvent:
{
// look at this packet; I have a feeling we need to deprecate it - MARCM
UT_ASSERT_HARMLESS(UT_NOT_IMPLEMENTED);
return true;
}
default:
break;
}
return false;
}