nn::cec::CTR::MessageBox::OpenMessageBox Member Function

Syntax

nn::Result OpenMessageBox(
     const TitleId cecTitleId,
     const u32 privateId
);

Arguments

Name Description
in cecTitleId StreetPass ID
in privateId Specify the same value that was specified when the box was created using CreateMessageBox. You will not be able to access the box if you specify any other value.

Return Values

nn::Result

Value Description
ResultSuccess Process succeeded.
ResultNoData Box does not exist.
ResultNotAuthorized Unable to access because the private IDs are different.
ResultStateBusy Unable to access because the daemon is busy (BUSY state). This may succeed if you wait some time before accessing again.
A value other than the above. Operation failed.

Description

Opens a MessageBox. You must use this function to open a box before you can access the messages within it.

When this function is called, the CEC daemon operating in the background stops. Be aware that background communication might be interrupted.→ CecControl::StopScanning
Call the CloseMessageBox function when you have finished accessing the box.
After you call this function, the CEC daemon will not start running until you call the CloseMessageBox function. Open message boxes only to set a send message or get a received message; do not leave them open at any other time. One safe implementation is to treat the Open-to-Close interval as a single unit of processing and mutually exclude Sleep Mode during that time.

Error Handling

The following simplified C++ code provides guidelines for error handling.
It shows the process flow of opening a box. If no box exists, this code sample creates one with CreateMessageBox.
    nn::Result result = OpenMessageBox();
    if(result.IsFailure())
    {
        if(result == nn::cec::ResultNoData())
        {
            // If no MessageBox exists
            // Prompt the user when creating a MessageBox
            // Create MessageBox
            result = CreateMessageBox();
            if(result.IsFailure())
            {
                if(result == nn::cec::ResultBoxAlreadyExists())
                {
                    // If a box seems to exist, but it won't open -> a box exists whose lower 8 bits of its ID are different
                    // If the CecTitleId is specified correctly, this state will never occur.
                    // This state occurs when the variation value was set unintentionally in MakeCecTitleId.
                    // If you need to delete and recreate it -> DeleteMessageBox(titleId);
                }
                else if(result == nn::cec::ResultBoxNumFull())
                {
                    // Number of boxes has reached maximum
                    // Prompt the user to delete the box of some other application
                }
                else if(result == nn::cec::ResultStateBusy())
                {
                    // Daemon is running
                    // This state will never normally occur, but it might be possible to succeed by retrying
                }
                else if(result == nn::cec::ResultInvalidArgument() 
                     || result == nn::cec::ResultTooLarge() 
                     || result == nn::cec::ResultInvalidData() )
                {
                    // Mistake in an argument, box icon, or similar
                }
                return result;  // Failure
            }
            // If CreateMessageBox succeeds, the box is opened.
        }
        else if(result == nn::cec::ResultNotAuthorized())
        {
            // Private ID does not match
            return result;  // Failure
            // If you need to delete and recreate it -> DeleteMessageBox(titleId);
        }
        else if(result.GetDescription() == Result::DESCRIPTION_BUSY)
        {
            // Daemon is running
            // This state will never normally occur, but it might be possible to succeed by retrying
            return result;  // Failure
        }
        else
        {
            // Err
            return result;  // Failure
        }
    }
    return result;  // Success
    

Revision History

2011/01/19
Added description of error handling.
2010/06/14
Initial version.

CONFIDENTIAL