コード例 #1
0
ファイル: ArpMessage.cpp プロジェクト: tgkokk/Sequitur
BMessage& ArpUpdateMessage(BMessage& to, const BMessage& msg)
{
	char* name;
	type_code type;
	long count;
	for( int32 i=0; !msg.GetInfo(B_ANY_TYPE,i,&name,&type,&count);
		i++ ) {
		bool all_gone = false;
		for( int32 j=0; j<count; j++ ) {
			type_code dummy;
			bool fixedSize=true;
			msg.GetInfo(name, &dummy, &fixedSize);
			const void* data;
			ssize_t size;
			if( !msg.FindData(name,type,j,&data,&size) ) {
				if( !all_gone ) {
					if( type == B_MESSAGE_TYPE ) {
						BMessage oldMsg;
						BMessage newMsg;
						if( !to.FindMessage(name,j,&oldMsg) &&
							!msg.FindMessage(name,j,&newMsg) ) {
							ArpUpdateMessage(oldMsg, newMsg);
							to.ReplaceMessage(name,j,&oldMsg);
						} else {
							all_gone = true;
						}
					}
					if( to.ReplaceData(name,type,j,data,size) ) {
						long cnt=0;
						type_code mtype = type;
						if( !to.GetInfo(name,&mtype,&cnt) ) {
							for( int32 k=cnt-1; k>=j; k-- ) {
								to.RemoveData(name,k);
							}
						}
						all_gone = true;
					}
				}
				if( all_gone ) {
					to.AddData(name,type,data,size,fixedSize);
				}
			}
		}
	}
	return to;
}
コード例 #2
0
ファイル: ArpMessage.cpp プロジェクト: tgkokk/Sequitur
ArpMessage&	ArpMessage::Update(const BMessage& msg)
{
	if( this ) ArpUpdateMessage(*this, msg);
	
#if 0
	if( this ) {
		char* name;
		type_code type;
		long count;
		for( int32 i=0; !msg.GetInfo(B_ANY_TYPE,i,&name,&type,&count);
			i++ ) {
			bool all_gone = false;
			for( int32 j=0; j<count; j++ ) {
				const void* data;
				ssize_t size;
				if( !msg.FindData(name,type,j,&data,&size) ) {
					if( !all_gone &&
						ReplaceData(name,type,j,data,size) ) {
						long cnt=0;
						type_code mtype = type;
						if( !GetInfo(name,&mtype,&cnt) ) {
							for( int32 k=cnt-1; k>=j; k-- ) {
								RemoveData(name,k);
							}
						}
						all_gone = true;
					}
					if( all_gone ) {
						AddData(name,type,data,size);
					}
				}
			}
		}
	}
#endif

	return *this;
}
コード例 #3
0
ファイル: ArpConfigureFile.cpp プロジェクト: dtbinh/Sequitur
void ArpConfigureFile::MessageReceived(BMessage* message)
{
    if( !message ) return;

    ArpD(cdb << ADH << "ArpConfigureFile received message: "
         << *message << endl);

    if( message->what == B_NODE_MONITOR && mWatcher.IsValid() ) {

        int32 opcode;
        if( message->FindInt32("opcode", &opcode) == B_OK
                && opcode == B_ENTRY_MOVED ) {
            entry_ref ref;
            const char* name;
            if( message->FindInt32("device", &ref.device) == B_OK
                    && message->FindInt64("to directory", &ref.directory) == B_OK
                    && message->FindString("name", &name) == B_OK ) {

                ref.set_name(name);
                mFile = ref;
            }
        }

        if( mWatchMessage ) {
            BMessage newMsg(*mWatchMessage);
            ArpUpdateMessage(newMsg, *message);
            mWatcher.SendMessage(&newMsg);
        } else {
            mWatcher.SendMessage(message);
        }

        return;
    }

    inherited::MessageReceived(message);
}