Back to index

im-sdk  12.3.91
IMProtocol.cpp
Go to the documentation of this file.
00001 #include <config.h>
00002 #include <stdio.h>
00003 #include "IMProtocol.hh"
00004 #include "IMState.hh"
00005 #include "ICState.hh"
00006 
00007 void
00008 IMProtocol::add_imstate(
00009     IMState *pims
00010 )
00011 {
00012     immap[pims->get_im_id()] = pims;
00013 }
00014 
00015 void
00016 IMProtocol::remove_imstate(
00017     IMState *pims
00018 )
00019 {
00020     immap.erase(pims->get_im_id());
00021 }
00022 
00023 
00024 bool
00025 IMProtocol::dispatch(
00026     CARD16BIT im_id,
00027     CARD16BIT ic_id,
00028     void *message
00029 )
00030 {
00031     if (ic_id == INVALID_CONTEXT_ID) {
00032        IMState *pims = get_imstate(im_id);
00033        return pims->deliver(message);
00034     }
00035     ICState *pics = get_icstate(im_id, ic_id);
00036 
00037     if (!pics) {
00038        LOG_ERROR("Invalid im_id and ic_id (%d, %d)",
00039                 (int) im_id, (int) ic_id);
00040        return false;
00041     }
00042 
00043     return pics->deliver(message);
00044 }
00045 
00046 IMProtocol::IMProtocol(
00047     IMAccept *pima
00048 )
00049 {
00050     pimaccept = pima;
00051 }
00052 
00053 IMProtocol::~IMProtocol()
00054 {
00055     destroy_all(immap);
00056 }
00057 
00058 /* Local Variables: */
00059 /* c-file-style: "iiim-project" */
00060 /* End: */