Added class AutoReply.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1594 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
//
|
//
|
||||||
// Author
|
// Author
|
||||||
// Ithamar R. Adema
|
// Ithamar R. Adema
|
||||||
|
// Michael Pfeiffer
|
||||||
//
|
//
|
||||||
// This application and all source files used in its construction, except
|
// This application and all source files used in its construction, except
|
||||||
// where noted, are licensed under the MIT License, and have been written
|
// where noted, are licensed under the MIT License, and have been written
|
||||||
@@ -34,8 +35,14 @@
|
|||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
#include <Messenger.h>
|
||||||
|
#include <Roster.h>
|
||||||
|
#include <String.h>
|
||||||
|
|
||||||
#include "BeUtils.h"
|
#include "BeUtils.h"
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
// TestForAddonExistence
|
// TestForAddonExistence
|
||||||
//
|
//
|
||||||
@@ -59,3 +66,27 @@ status_t TestForAddonExistence(const char* name, directory_which which, const ch
|
|||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Implementation of AutoReply
|
||||||
|
|
||||||
|
AutoReply::AutoReply(BMessage* sender, uint32 what)
|
||||||
|
: fSender(sender)
|
||||||
|
, fReply(what)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
AutoReply::~AutoReply() {
|
||||||
|
fSender->SendReply(&fReply);
|
||||||
|
delete fSender;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MimeTypeForSender(BMessage* sender, BString& mime) {
|
||||||
|
BMessenger msgr = sender->ReturnAddress();
|
||||||
|
team_id team = msgr.Team();
|
||||||
|
app_info info;
|
||||||
|
if (be_roster->GetRunningAppInfo(team, &info) == B_OK) {
|
||||||
|
mime = info.signature;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|||||||
@@ -72,4 +72,19 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Automatically send a reply to sender on destruction of object
|
||||||
|
// and delete sender
|
||||||
|
class AutoReply {
|
||||||
|
BMessage* fSender;
|
||||||
|
BMessage fReply;
|
||||||
|
|
||||||
|
public:
|
||||||
|
AutoReply(BMessage* sender, uint32 what);
|
||||||
|
~AutoReply();
|
||||||
|
void SetReply(BMessage* m) { fReply = *m; }
|
||||||
|
};
|
||||||
|
|
||||||
|
// mimetype from sender
|
||||||
|
bool MimeTypeForSender(BMessage* sender, BString& mime);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user