Added class AutoReply.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1594 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Pfeiffer
2002-10-22 15:56:40 +00:00
parent 87790d71e6
commit dda672d898
2 changed files with 46 additions and 0 deletions
+31
View File
@@ -9,6 +9,7 @@
//
// Author
// Ithamar R. Adema
// Michael Pfeiffer
//
// This application and all source files used in its construction, except
// 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
// DEALINGS IN THE SOFTWARE.
/*****************************************************************************/
#include <Messenger.h>
#include <Roster.h>
#include <String.h>
#include "BeUtils.h"
// ---------------------------------------------------------------
// TestForAddonExistence
//
@@ -59,3 +66,27 @@ status_t TestForAddonExistence(const char* name, directory_which which, const ch
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;
}
+15
View File
@@ -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