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

Syntax

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

Parameters

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
Result::IsSuccess 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). It may succeed if you wait some time before accessing again.
ResultBufferFull Could not allocate the memory required for the process.
Any other value Process failed.

Description

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

Note: When this function is called, the CEC (StreetPass) daemon operating in the background stops. Note 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. Do not leave in an open state other than when setting a send message or getting a received message.
With the Open - Message Read/Write - Close interval as a single processing unit, exclude Sleep and the HOME Menu during this interval.

Error Handling

The following simplified C++ code provides guidelines for error handling.
This is the process flow for opening a message 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 normally never occurs, 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 == nn::cec::ResultStateBusy())
        {
            // Daemon is running
            // This state normally never occurs, 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 a description of error handling.
2010/06/14
Initial version.

CONFIDENTIAL