Ticket #2873: mhegupdate.patch

File mhegupdate.patch, 42.8 KB (added by dm@…, 13 years ago)
  • libs/libmythfreemheg/Actions.cpp

     
    3737#include "Link.h"
    3838#include "TokenGroup.h"
    3939#include "Stream.h"
     40#include "Logging.h"
    4041
    4142
    4243// Temporary place-holder for actions we haven't done yet.
    43 class MHTemporary: public MHElemAction
     44class MHUnimplementedAction: public MHElemAction
    4445{
    4546public:
    46     MHTemporary(int nTag): MHElemAction("") { m_nTag = nTag; }
     47    MHUnimplementedAction(int nTag): MHElemAction("") { m_nTag = nTag; }
    4748    virtual void Initialise(MHParseNode *, MHEngine *) {}
    4849    virtual void PrintMe(FILE *fd, int /*nTabs*/) const { fprintf(fd, "****Missing action %d\n", m_nTag); }
    49     virtual void Perform(MHEngine *) { ASSERT(FALSE); }
     50    virtual void Perform(MHEngine *) { MHERROR(QString("Unimplemented action %1").arg(m_nTag)); }
    5051protected:
    5152    int m_nTag;
    5253};
    5354
    54 
    5555// ActionSequence.
    5656
    5757// Process the action set and create the action values.
     
    7171        case C_CALL_ACTION_SLOT: pAction = new MHCallActionSlot; break;
    7272        case C_CLEAR: pAction = new MHClear; break;
    7373        case C_CLONE: pAction = new MHClone; break;
    74         case C_CLOSE_CONNECTION: pAction = new MHTemporary(pElemAction->GetTagNo()); break; // ??
     74        case C_CLOSE_CONNECTION: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break; // ??
    7575        case C_DEACTIVATE: pAction = new MHActivate(":Deactivate", false); break;
    7676        case C_DEL_ITEM: pAction = new MHDelItem; break;
    77         case C_DESELECT: pAction = new MHTemporary(pElemAction->GetTagNo()); break; // Button
     77        case C_DESELECT: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break; // Button
    7878        case C_DESELECT_ITEM: pAction = new MHDeselectItem; break;
    7979        case C_DIVIDE: pAction = new MHDivide; break;
    8080        case C_DRAW_ARC: pAction = new MHDrawArcSector(":DrawArc", false); break;
     
    8888        case C_GET_AVAILABILITY_STATUS: pAction = new MHGetAvailabilityStatus; break;
    8989        case C_GET_BOX_SIZE: pAction = new MHGetBoxSize; break;
    9090        case C_GET_CELL_ITEM: pAction = new MHGetCellItem; break;
    91         case C_GET_CURSOR_POSITION: pAction = new MHTemporary(pElemAction->GetTagNo()); break; // ?
     91        case C_GET_CURSOR_POSITION: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break; // ?
    9292        case C_GET_ENGINE_SUPPORT: pAction = new MHGetEngineSupport; break;
    93         case C_GET_ENTRY_POINT: pAction = new MHTemporary(pElemAction->GetTagNo()); break; // EntryField
     93        case C_GET_ENTRY_POINT: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break; // EntryField
    9494        case C_GET_FILL_COLOUR: pAction = new MHGetFillColour; break;
    9595        case C_GET_FIRST_ITEM: pAction = new MHGetFirstItem; break;
    96         case C_GET_HIGHLIGHT_STATUS: pAction = new MHTemporary(pElemAction->GetTagNo()); break;// ?
    97         case C_GET_INTERACTION_STATUS: pAction = new MHTemporary(pElemAction->GetTagNo()); break;// ?
     96        case C_GET_HIGHLIGHT_STATUS: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break;// ?
     97        case C_GET_INTERACTION_STATUS: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break;// ?
    9898        case C_GET_ITEM_STATUS: pAction = new MHGetItemStatus; break;
    99         case C_GET_LABEL: pAction = new MHTemporary(pElemAction->GetTagNo()); break;// PushButton
    100         case C_GET_LAST_ANCHOR_FIRED: pAction = new MHTemporary(pElemAction->GetTagNo()); break;// HyperText
     99        case C_GET_LABEL: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break;// PushButton
     100        case C_GET_LAST_ANCHOR_FIRED: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break;// HyperText
    101101        case C_GET_LINE_COLOUR: pAction = new MHGetLineColour; break;
    102102        case C_GET_LINE_STYLE: pAction = new MHGetLineStyle; break;
    103103        case C_GET_LINE_WIDTH: pAction = new MHGetLineWidth; break;
    104104        case C_GET_LIST_ITEM: pAction = new MHGetListItem; break;
    105105        case C_GET_LIST_SIZE: pAction = new MHGetListSize; break;
    106         case C_GET_OVERWRITE_MODE: pAction = new MHTemporary(pElemAction->GetTagNo()); break;// ?
    107         case C_GET_PORTION: pAction = new MHTemporary(pElemAction->GetTagNo()); break;// Slider
     106        case C_GET_OVERWRITE_MODE: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break;// ?
     107        case C_GET_PORTION: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break;// Slider
    108108        case C_GET_POSITION: pAction = new MHGetPosition; break;
    109109        case C_GET_RUNNING_STATUS: pAction = new MHGetRunningStatus; break;
    110         case C_GET_SELECTION_STATUS: pAction = new MHTemporary(pElemAction->GetTagNo()); break;// ?
    111         case C_GET_SLIDER_VALUE: pAction = new MHTemporary(pElemAction->GetTagNo()); break;// Slider
    112         case C_GET_TEXT_CONTENT: pAction = new MHTemporary(pElemAction->GetTagNo()); break;// Text
     110        case C_GET_SELECTION_STATUS: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break;// ?
     111        case C_GET_SLIDER_VALUE: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break;// Slider
     112        case C_GET_TEXT_CONTENT: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break;// Text
    113113        case C_GET_TEXT_DATA: pAction = new MHGetTextData; break;
    114114        case C_GET_TOKEN_POSITION: pAction = new MHGetTokenPosition; break;
    115         case C_GET_VOLUME: pAction = new MHTemporary(pElemAction->GetTagNo()); break; // ?
     115        case C_GET_VOLUME: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break; // ?
    116116        case C_LAUNCH: pAction = new MHLaunch; break;
    117117        case C_LOCK_SCREEN: pAction = new MHLockScreen; break;
    118118        case C_MODULO: pAction = new MHModulo; break;
    119119        case C_MOVE: pAction = new MHMove; break;
    120120        case C_MOVE_TO: pAction = new MHMoveTo; break;
    121121        case C_MULTIPLY: pAction = new MHMultiply; break;
    122         case C_OPEN_CONNECTION: pAction = new MHTemporary(pElemAction->GetTagNo()); break; // ?
     122        case C_OPEN_CONNECTION: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break; // ?
    123123        case C_PRELOAD: pAction = new MHPreload; break;
    124124        case C_PUT_BEFORE: pAction = new MHPutBefore; break;
    125125        case C_PUT_BEHIND: pAction = new MHPutBehind; break;
     
    129129        case C_SCALE_BITMAP: pAction = new MHScaleBitmap; break;
    130130        case C_SCALE_VIDEO: pAction = new MHScaleVideo; break;
    131131        case C_SCROLL_ITEMS: pAction = new MHScrollItems; break;
    132         case C_SELECT: pAction = new MHTemporary(pElemAction->GetTagNo()); break; // Button
     132        case C_SELECT: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break; // Button
    133133        case C_SELECT_ITEM: pAction = new MHSelectItem; break;
    134134        case C_SEND_EVENT: pAction = new MHSendEvent; break;
    135135        case C_SEND_TO_BACK: pAction = new MHSendToBack; break;
    136136        case C_SET_BOX_SIZE: pAction = new MHSetBoxSize; break;
    137         case C_SET_CACHE_PRIORITY: pAction = new MHTemporary(pElemAction->GetTagNo()); break; // ?
    138         case C_SET_COUNTER_END_POSITION: pAction = new MHTemporary(pElemAction->GetTagNo()); break; // Stream
    139         case C_SET_COUNTER_POSITION: pAction = new MHTemporary(pElemAction->GetTagNo()); break; // Stream
    140         case C_SET_COUNTER_TRIGGER: pAction = new MHTemporary(pElemAction->GetTagNo()); break; // Stream
    141         case C_SET_CURSOR_POSITION: pAction = new MHTemporary(pElemAction->GetTagNo()); break; // ?
    142         case C_SET_CURSOR_SHAPE: pAction = new MHTemporary(pElemAction->GetTagNo()); break; // ?
     137        case C_SET_CACHE_PRIORITY: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break; // ?
     138        case C_SET_COUNTER_END_POSITION: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break; // Stream
     139        case C_SET_COUNTER_POSITION: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break; // Stream
     140        case C_SET_COUNTER_TRIGGER: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break; // Stream
     141        case C_SET_CURSOR_POSITION: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break; // ?
     142        case C_SET_CURSOR_SHAPE: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break; // ?
    143143        case C_SET_DATA: pAction = new MHSetData; break;
    144         case C_SET_ENTRY_POINT: pAction = new MHTemporary(pElemAction->GetTagNo()); break; // EntryField
     144        case C_SET_ENTRY_POINT: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break; // EntryField
    145145        case C_SET_FILL_COLOUR: pAction = new MHSetFillColour; break;
    146146        case C_SET_FIRST_ITEM: pAction = new MHSetFirstItem; break;
    147         case C_SET_FONT_REF: pAction = new MHTemporary(pElemAction->GetTagNo()); break; // Text
    148         case C_SET_HIGHLIGHT_STATUS: pAction = new MHTemporary(pElemAction->GetTagNo()); break; // ?
    149         case C_SET_INTERACTION_STATUS: pAction = new MHTemporary(pElemAction->GetTagNo()); break; // ?
    150         case C_SET_LABEL: pAction = new MHTemporary(pElemAction->GetTagNo()); break; // PushButton
     147        case C_SET_FONT_REF: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break; // Text
     148        case C_SET_HIGHLIGHT_STATUS: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break; // ?
     149        case C_SET_INTERACTION_STATUS: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break; // ?
     150        case C_SET_LABEL: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break; // PushButton
    151151        case C_SET_LINE_COLOUR: pAction = new MHSetLineColour; break;
    152152        case C_SET_LINE_STYLE: pAction = new MHSetLineStyle; break;
    153153        case C_SET_LINE_WIDTH: pAction = new MHSetLineWidth; break;
    154         case C_SET_OVERWRITE_MODE: pAction = new MHTemporary(pElemAction->GetTagNo()); break; // EntryField
    155         case C_SET_PALETTE_REF: pAction = new MHTemporary(pElemAction->GetTagNo()); break; // Visible
    156         case C_SET_PORTION: pAction = new MHTemporary(pElemAction->GetTagNo()); break; // Slider
     154        case C_SET_OVERWRITE_MODE: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break; // EntryField
     155        case C_SET_PALETTE_REF: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break; // Visible
     156        case C_SET_PORTION: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break; // Slider
    157157        case C_SET_POSITION: pAction = new MHSetPosition; break;
    158         case C_SET_SLIDER_VALUE: pAction = new MHTemporary(pElemAction->GetTagNo()); break; // Slider
    159         case C_SET_SPEED: pAction = new MHTemporary(pElemAction->GetTagNo()); break; // ?
     158        case C_SET_SLIDER_VALUE: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break; // Slider
     159        case C_SET_SPEED: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break; // ?
    160160        case C_SET_TIMER: pAction = new MHSetTimer; break;
    161161        case C_SET_TRANSPARENCY: pAction = new MHSetTransparency; break;
    162162        case C_SET_VARIABLE: pAction = new MHSetVariable; break;
    163         case C_SET_VOLUME: pAction = new MHTemporary(pElemAction->GetTagNo()); break; // ?
     163        case C_SET_VOLUME: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break; // ?
    164164        case C_SPAWN: pAction = new MHSpawn; break;
    165         case C_STEP: pAction = new MHTemporary(pElemAction->GetTagNo()); break; // Slider
     165        case C_STEP: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break; // Slider
    166166        case C_STOP: pAction = new MHStop; break;
    167167        case C_STORE_PERSISTENT: pAction = new MHPersistent(":StorePersistent", false); break;
    168168        case C_SUBTRACT: pAction = new MHSubtract; break;
    169169        case C_TEST_VARIABLE: pAction = new MHTestVariable; break;
    170         case C_TOGGLE: pAction = new MHTemporary(pElemAction->GetTagNo()); break; // Button
     170        case C_TOGGLE: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break; // Button
    171171        case C_TOGGLE_ITEM: pAction = new MHToggleItem; break;
    172172        case C_TRANSITION_TO: pAction = new MHTransitionTo; break;
    173173        case C_UNLOAD: pAction = new MHUnload; break;
    174174        case C_UNLOCK_SCREEN: pAction = new MHUnlockScreen; break;
    175175        // UK MHEG added actions.
    176176        case C_SET_BACKGROUND_COLOUR: pAction = new MHSetBackgroundColour; break;
    177         case C_SET_CELL_POSITION: pAction = new MHTemporary(pElemAction->GetTagNo()); break; // ?
     177        case C_SET_CELL_POSITION: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break; // ?
    178178        case C_SET_INPUT_REGISTER: pAction = new MHSetInputRegister; break;
    179179        case C_SET_TEXT_COLOUR: pAction = new MHSetTextColour; break;
    180180        case C_SET_FONT_ATTRIBUTES: pAction = new MHSetFontAttributes; break;
    181181        case C_SET_VIDEO_DECODE_OFFSET: pAction = new MHSetVideoDecodeOffset; break;
    182182        case C_GET_VIDEO_DECODE_OFFSET: pAction = new MHGetVideoDecodeOffset; break;
    183         case C_GET_FOCUS_POSITION: pAction = new MHTemporary(pElemAction->GetTagNo()); break; // HyperText
    184         case C_SET_FOCUS_POSITION: pAction = new MHTemporary(pElemAction->GetTagNo()); break; // HyperText
     183        case C_GET_FOCUS_POSITION: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break; // HyperText
     184        case C_SET_FOCUS_POSITION: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break; // HyperText
    185185        case C_SET_BITMAP_DECODE_OFFSET: pAction = new MHSetBitmapDecodeOffset; break;
    186186        case C_GET_BITMAP_DECODE_OFFSET: pAction = new MHGetBitmapDecodeOffset; break;
    187         case C_SET_SLIDER_PARAMETERS: pAction = new MHTemporary(pElemAction->GetTagNo()); break; // ?
     187        case C_SET_SLIDER_PARAMETERS: pAction = new MHUnimplementedAction(pElemAction->GetTagNo()); break; // ?
    188188
    189189        default:
    190             ASSERT(FALSE); // So we find out about these when debugging.
     190            MHLOG(MHLogWarning, QString("Unknown action %1").arg(pElemAction->GetTagNo()));
    191191            // Future proofing: ignore any actions that we don't know about.
    192192            // Obviously these can only arise in the binary coding.
    193193            pAction = NULL;
  • libs/libmythfreemheg/Engine.cpp

     
    8383        {
    8484             startObj.m_GroupId.Copy(MHOctetString("~//startup"));
    8585             if (! Launch(startObj))
    86              {
    87                  MHLOG(MHLogError, "Unable to launch application");
    8886                 return -1;
    89              }
    9087        }
    9188        m_fBooting = false;
    9289    }
     
    122119
    123120        if (! m_EventQueue.isEmpty()) {
    124121            MHAsynchEvent *pEvent = m_EventQueue.first();
    125             MHLOG(MHLogLinks, QString("Asynchronous event dequeued - %1")
    126                 .arg(MHLink::EventTypeToString(pEvent->eventType)));
     122            MHLOG(MHLogLinks, QString("Asynchronous event dequeued - %1 from %2")
     123                .arg(MHLink::EventTypeToString(pEvent->eventType))
     124                .arg(pEvent->pEventSource->m_ObjectReference.Printable()));
    127125            CheckLinks(pEvent->pEventSource->m_ObjectReference, pEvent->eventType, pEvent->eventData);
    128126            m_EventQueue.removeFirst();
    129127        }
     
    348346    // Remove any occurrences of x/../
    349347    int nPos;
    350348    while ((nPos = csPath.find("/../")) >= 0) {
    351         ASSERT(false); // To check.
    352349        int nEnd = nPos+4;
    353350        while (nPos >= 1 && csPath[nPos-1] != '/') nPos--;
    354351        csPath = csPath.left(nPos) + csPath.mid(nEnd);
     
    470467// Add and remove links to and from the active link table.
    471468void MHEngine::AddLink(MHLink *pLink)
    472469{
    473 #ifdef _DEBUG
    474     // Should not be there already.
    475     for (int i = 0; i < m_LinkTable.count(); i++) ASSERT(pLink != m_LinkTable.at(i));
    476 #endif
    477470    m_LinkTable.append(pLink);
    478471}
    479472
    480473void MHEngine::RemoveLink(MHLink *pLink)
    481474{
    482     bool fRes = m_LinkTable.removeRef(pLink);
    483     ASSERT(fRes); // The link should have been there.
     475    (void)m_LinkTable.removeRef(pLink);
    484476}
    485477
    486478// Called when a link fires to add the actions to the action stack.
  • libs/libmythfreemheg/Ingredients.cpp

     
    2626#include "ASN1Codes.h"
    2727#include "Actions.h"
    2828#include "Engine.h"
     29#include "Logging.h"
    2930
    3031
    3132MHIngredient::MHIngredient()
     
    5657void MHIngredient::Initialise(MHParseNode *p, MHEngine *engine)
    5758{
    5859    MHRoot::Initialise(p, engine);
    59     ASSERT(m_ObjectReference.m_nObjectNo > 0);
    6060    MHParseNode *pIA = p->GetNamedArg(C_INITIALLY_ACTIVE);
    6161    if (pIA) m_fInitiallyActive = pIA->GetArgN(0)->GetBoolValue();
    6262
     
    152152    if (m_ContentType == IN_ReferencedContent) {
    153153        m_ContentRef.m_ContentRef.Copy(included);
    154154    }
    155     else {
    156         ASSERT(m_ContentType == IN_IncludedContent);
     155    else if (m_ContentType == IN_IncludedContent) {
    157156        m_IncludedContent.Copy(included);
    158157       
    159158    }
     159    else MHLOG(MHLogWarning, "SetData with no content"); // MHEG Error
    160160    ContentPreparation(engine);
    161161}
    162162
    163163void MHIngredient::SetData(const MHContentRef &referenced, bool /*fSizeGiven*/, int size, bool fCCGiven, int /*cc*/, MHEngine *engine)
    164164{
    165     ASSERT(m_ContentType == IN_ReferencedContent);
     165    if (m_ContentType != IN_ReferencedContent)
     166        MHERROR("SetData with referenced content applied to an ingredient without referenced content");
    166167    m_ContentRef.Copy(referenced);
    167168    m_nContentSize = size;
    168169    if (fCCGiven) m_nCCPrio = m_nOrigCCPrio;
  • libs/libmythfreemheg/ParseText.cpp

     
    475475
    476476        case '`': // Start of a string using base 64
    477477            // These can, presumably span lines.
    478             ASSERT(FALSE); // TODO
     478            MHERROR("Base 64 string is not implemented");
    479479            break;
    480480
    481481        case '#': // Start of 3-byte hex constant.
    482             ASSERT(FALSE); // TODO
     482            MHERROR("3-byte hex constant is not implemented");
    483483            break;
    484484
    485485        case '-': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
     
    495495                m_nInt = m_ch - '0';
    496496                GetNextChar();
    497497                if (m_nInt == 0 && (m_ch == 'x' || m_ch == 'X')) {
    498                     ASSERT(FALSE); // TODO
     498                    MHERROR("Hex constant is not implemented");
    499499                }
    500500                while (m_ch >= '0' && m_ch <= '9') {
    501501                    m_nInt = m_nInt * 10 + m_ch - '0';
     
    791791
    792792        case PTEnum:
    793793            {
    794                 pRes = new MHPEnum(m_nInt); ASSERT(m_nInt > 0);
     794                pRes = new MHPEnum(m_nInt);
    795795                NextSym();
    796796                break;
    797797            }
  • libs/libmythfreemheg/ParseBinary.cpp

     
    5353// Parse a string argument.  ASN1 strings can include nulls as valid characters.
    5454void MHParseBinary::ParseString(int endStr, MHOctetString &str)
    5555{
    56     ASSERT(endStr != INDEFINITE_LENGTH); // TODO: Don't deal with indefinite length at the moment.
     56     // TODO: Don't deal with indefinite length at the moment.
     57    if (endStr == INDEFINITE_LENGTH)
     58        MHERROR("Indefinite length strings are not implemented");
    5759    int nLength = endStr - m_p;
    5860    unsigned char *stringValue = (unsigned char*)malloc(endStr - m_p);
    5961    unsigned char *p = stringValue;
     
    6769{
    6870    int intVal = 0;
    6971    bool firstByte = true;
    70     ASSERT(endInt != INDEFINITE_LENGTH); // TODO: Don't deal with indefinite length at the moment.
     72    if (endInt == INDEFINITE_LENGTH)
     73        MHERROR("Indefinite length integers are not implemented");
    7174    while (m_p < endInt) {
    7275        unsigned char ch = GetNextChar();
    7376        // Integer values are signed so if the top bit is set in the first byte
     
    228231                {
    229232                    // Everything else has either no argument or is self-describing
    230233                    // TODO: Handle indefinite length.
    231                     ASSERT(endOfItem != INDEFINITE_LENGTH); // For the moment.
     234                    if (endOfItem == INDEFINITE_LENGTH)
     235                        MHERROR("Indefinite length arguments are not implemented");
    232236                    while (m_p < endOfItem) {
    233237                        pNode->AddArg(DoParse());
    234238                    }
     
    274278        case U_SEQUENCE: // Sequence
    275279            {
    276280                MHParseSequence *pNode = new MHParseSequence();
    277                 ASSERT(endOfItem != INDEFINITE_LENGTH); // TODO: Implement this.
     281                if (endOfItem == INDEFINITE_LENGTH)
     282                    MHERROR("Indefinite length sequences are not implemented");
    278283                try {
    279284                    while (m_p < endOfItem) {
    280285                        pNode->Append(DoParse());
     
    285290                    delete pNode;
    286291                    throw;
    287292                }
    288                 ASSERT(m_p == endOfItem);
    289293                return pNode;
    290294            }
    291295        default:
    292             ASSERT(FALSE);
    293             throw "Unknown universal";
     296            MHERROR(QString("Unknown universal %1").arg(tagNumber));
    294297        }
    295298    }
    296299}
  • libs/libmythfreemheg/Text.cpp

     
    168168//  else m_Font.Copy(engine->m_DefaultFont);
    169169    if (m_OriginalTextColour.IsSet()) m_textColour.Copy(m_OriginalTextColour);
    170170    else engine->GetDefaultTextColour(m_textColour);
    171     ASSERT(m_textColour.IsSet());
    172171    if (m_OriginalBgColour.IsSet()) m_bgColour.Copy(m_OriginalBgColour);
    173172    else engine->GetDefaultBGColour(m_bgColour);
    174     ASSERT(m_bgColour.IsSet());
    175173    if (m_OriginalFontAttrs.Size() > 0) m_fontAttrs.Copy(m_OriginalFontAttrs);
    176174    else engine->GetDefaultFontAttrs(m_fontAttrs);
    177175    MHVisible::Preparation(engine);
     
    184182void MHText::ContentPreparation(MHEngine *engine)
    185183{
    186184    MHVisible::ContentPreparation(engine);
    187     ASSERT(m_ContentType != IN_NoContent);
     185    if (m_ContentType == IN_NoContent)
     186        MHERROR("Text object must have content");
    188187    if (m_ContentType == IN_IncludedContent) CreateContent(m_IncludedContent.Bytes(), m_IncludedContent.Size(), engine);
    189188}
    190189
     
    243242    }
    244243    else { // Textual form.
    245244        const unsigned char *str = attrs.Bytes();
    246         ASSERT(str != NULL);
    247245        const char *p = (const char *)str;
    248246        char *q = strchr(p, '.'); // Find the terminating dot
    249247        if (q != NULL) { // plain, italic etc.
     
    305303// A line consists of one or more sequences of text items.
    306304class MHTextLine {
    307305public:
    308     MHTextLine(): m_nLineWidth(0) {}
     306    MHTextLine(): m_nLineWidth(0), m_nLineHeight(0), m_nDescent(0) {}
    309307    ~MHTextLine();
    310308    MHSequence <MHTextItem *> m_Items;
    311309    int m_nLineWidth;
     310    int m_nLineHeight;
     311    int m_nDescent;
    312312};
    313313
    314314MHTextLine::~MHTextLine()
     
    439439            int nFullText = pItem->m_nUnicode;
    440440            // Get the box size and update pItem->m_nUnicode to the number that will fit.
    441441            QRect rect = m_pDisplay->GetBounds(pItem->m_Unicode, pItem->m_nUnicode, m_nBoxWidth - pLine->m_nLineWidth);
    442             if (nFullText == pItem->m_nUnicode || ! m_fTextWrap) {
    443                 // All the characters fit or we're not wrapping.
    444                 pItem->m_Width = rect.width();
    445                 pLine->m_nLineWidth += rect.width();
    446             }
    447442
    448             else if (m_fTextWrap) { // No, we have to word-wrap.
     443            if (nFullText != pItem->m_nUnicode && m_fTextWrap) { // Doesn't fit, we have to word-wrap.
    449444                int nTruncated = pItem->m_nUnicode; // Just in case.
    450445                // Now remove characters until we find a word-break character.
    451446                while (pItem->m_nUnicode > 0 && pItem->m_Unicode[pItem->m_nUnicode] != ' ') pItem->m_nUnicode--;
     
    473468                // we are centering or right aligning the text we'll get it wrong.
    474469                while (pItem->m_nUnicode > 1 && pItem->m_Unicode[pItem->m_nUnicode-1] == ' ') pItem->m_nUnicode--;
    475470                rect = m_pDisplay->GetBounds(pItem->m_Unicode, pItem->m_nUnicode);
    476                 pItem->m_Width = rect.width();
    477                 pLine->m_nLineWidth += rect.width();
    478471            }
     472
     473            pItem->m_Width = rect.width();
     474            pLine->m_nLineWidth += rect.width();
     475            if (rect.height() > pLine->m_nLineHeight) pLine->m_nLineHeight = rect.height();
     476            if (rect.bottom() > pLine->m_nDescent) pLine->m_nDescent = rect.bottom();
    479477        }
    480478    }
    481479
     
    494492        int xOffset = 0;
    495493        if (m_HorizJ == End) xOffset = m_nBoxWidth - pLine->m_nLineWidth;
    496494        else if (m_HorizJ == Centre) xOffset = (m_nBoxWidth - pLine->m_nLineWidth)/2;
    497         //ASSERT(xOffset >= 0);
    498495
    499496        for (int j = 0; j < pLine->m_Items.Size(); j++) {
    500497            MHTextItem *pItem = pLine->m_Items.GetAt(j);
     
    502499            for (int k = 0; k < pItem->m_nTabCount; k++) xOffset += TABSTOP - xOffset % TABSTOP;
    503500
    504501            if (! pItem->m_Unicode.isEmpty()) { // We may have blank lines.
    505                 m_pDisplay->AddText(xOffset, yOffset + lineSpace,
     502                m_pDisplay->AddText(xOffset, yOffset + (pLine->m_nLineHeight + lineSpace)/2 - pLine->m_nDescent,
    506503                    pItem->m_Unicode.left(pItem->m_nUnicode), pItem->m_Colour);
    507504            }
    508505            xOffset += pItem->m_Width;
  • libs/libmythfreemheg/Logging.h

     
    2323#define LOGGING_H
    2424
    2525#include <qglobal.h> // For Q_ASSERT
     26#include <qstring.h> // For QString
    2627
    27 #ifdef ASSERT
    28 #undef ASSERT
    29 #endif
     28#include "freemheg.h" // For MHLogError
    3029
    31 #define ASSERT(f)          Q_ASSERT(f)
     30#define MHASSERT(f)          Q_ASSERT(f)
    3231
    3332extern int __mhlogoptions;
    3433extern void __mhlog(QString logtext);
  • libs/libmythfreemheg/BaseClasses.h

     
    2121
    2222#if !defined(BASECLASSES_H)
    2323#define BASECLASSES_H
    24 #include <stdio.h>
    25 #include <assert.h>
     24
    2625#include "../../config.h"
    2726#ifdef HAVE_MALLOC_H
    2827#include <malloc.h>
     
    3029
    3130#include <qstring.h>
    3231
     32#include "Logging.h" // For MHASSERT
     33
    3334class MHEngine;
    3435
    3536// These templates should really be obtained from a library.  They are defined here to
     
    4445        // Get the current size.
    4546        int Size() const { return m_VecSize; }
    4647        // Get an element at a particular index.
    47         BASE GetAt(int i) const { ASSERT(i >= 0 && i < m_VecSize); return m_Values[i]; }
     48        BASE GetAt(int i) const { MHASSERT(i >= 0 && i < m_VecSize); return m_Values[i]; }
    4849        BASE operator[](int i) const { return GetAt(i); }
    4950        // Add a new element at position n and move the existing element at that position
    5051        // and anything above it up one place.
    5152        void InsertAt(BASE b, int n) {
    52             ASSERT(n >= 0 && n <= m_VecSize);
     53            MHASSERT(n >= 0 && n <= m_VecSize);
    5354            BASE *ptr = (BASE*)realloc(m_Values, (m_VecSize+1) * sizeof(BASE));
    5455            if (ptr == NULL) throw "Out of Memory";
    5556            m_Values = ptr;
     
    6162        void Append(BASE b) { InsertAt(b, m_VecSize); }
    6263        // Remove an element and shift all the others down.
    6364        void RemoveAt(int i) {
    64             ASSERT(i >= 0 && i < m_VecSize);
     65            MHASSERT(i >= 0 && i < m_VecSize);
    6566            for (int j = i+1; j < m_VecSize; j++) m_Values[j-1] = m_Values[j];
    6667            m_VecSize--;
    6768        }
     
    8485        bool Empty() const { return Size() == 0; }
    8586        // Pop an item from the stack.
    8687        BASE Pop() {
    87             ASSERT(MHSequence<BASE>::m_VecSize > 0);
     88            MHASSERT(MHSequence<BASE>::m_VecSize > 0);
    8889            return MHSequence<BASE>::m_Values[--MHSequence<BASE>::m_VecSize];
    8990        }
    9091        // Push an element on the stack.
    9192        void Push(BASE b) { Append(b); }
    9293        // Return the top of the stack.
    9394        BASE Top() {
    94             ASSERT(MHSequence<BASE>::m_VecSize > 0);
     95            MHASSERT(MHSequence<BASE>::m_VecSize > 0);
    9596            return MHSequence<BASE>::m_Values[MHSequence<BASE>::m_VecSize-1];
    9697        }
    9798        int Size() const { return MHSequence<BASE>::Size(); }
     
    115116    // Comparison - returns <0, =0, >0 depending on the ordering.
    116117    int Compare(const MHOctetString &str) const;
    117118    bool Equal(const MHOctetString &str) const { return Compare(str) == 0; }
    118     unsigned char GetAt(int i) const { ASSERT(i >= 0 && i < Size()); return m_pChars[i]; }
     119    unsigned char GetAt(int i) const { MHASSERT(i >= 0 && i < Size()); return m_pChars[i]; }
    119120    const unsigned char *Bytes() const { return m_pChars; } // Read-only pointer to the buffer.
    120121    void Append(const MHOctetString &str); // Add text to the end of the string.
    121122
  • libs/libmythfreemheg/Bitmap.cpp

     
    9292void MHBitmap::ContentPreparation(MHEngine *engine)
    9393{
    9494    MHVisible::ContentPreparation(engine);
    95     ASSERT(m_ContentType != IN_NoContent);
    96     ASSERT(m_ContentType != IN_IncludedContent); // We can't handle included content at the moment.
    97 //  if (m_ContentType == IN_IncludedContent) CreateContent(m_IncludedContent.Bytes(), m_IncludedContent.Size());
     95    if (m_ContentType == IN_NoContent)
     96        MHERROR("Bitmap must contain a content");
     97    if (m_ContentType == IN_IncludedContent) // We can't handle included content at the moment.
     98        MHERROR("Included content in bitmap is not implemented");
    9899}
    99100
    100101// Decode the content.
     
    130131{
    131132    // The object transparency isn't actually used in UK MHEG.
    132133    // We want a value between 0 and 255
    133     ASSERT(nTransPerCent >= 0 && nTransPerCent <= 100); // This should really be a check.
     134    if (nTransPerCent < 0) nTransPerCent = 0; // Make sure it's in the bounds
     135    if (nTransPerCent > 100) nTransPerCent = 100;
    134136    m_nTransparency = ((nTransPerCent * 255) + 50) / 100;
    135137}
    136138
  • libs/libmythfreemheg/Groups.cpp

     
    3535#include "DynamicLineArt.h"
    3636#include "Link.h"
    3737#include "TokenGroup.h"
     38#include "Logging.h"
    3839
    3940MHGroup::MHGroup()
    4041{
     
    4849    engine->GetGroupId().Copy(""); // Set to empty before we start (just in case).
    4950    MHRoot::Initialise(p, engine);
    5051    // Must be an external reference with an object number of zero.
    51     ASSERT(m_ObjectReference.m_nObjectNo == 0 && m_ObjectReference.m_GroupId.Size() != 0);
     52    if (m_ObjectReference.m_nObjectNo != 0 || m_ObjectReference.m_GroupId.Size() == 0)
     53        MHERROR("Object reference for a group object must be zero and external");
    5254    // Set the group id for the rest of the group to this.
    5355    engine->GetGroupId().Copy(m_ObjectReference.m_GroupId);
    5456    // Some of the information is irrelevant.
     
    99101            case C_TOKEN_GROUP: pIngredient = new MHTokenGroup; break;
    100102            case C_LIST_GROUP: pIngredient = new MHListGroup; break;
    101103            default:
    102                 ASSERT(FALSE); // So we find out about these when debugging.
     104                MHLOG(MHLogWarning, QString("Unknown ingredient %1").arg(pItem->GetTagNo()));
    103105                // Future proofing: ignore any ingredients that we don't know about.
    104106                // Obviously these can only arise in the binary coding.
    105107            }
     
    404406    // Moving cursor
    405407    MHParseNode *pMovingCursor = p->GetNamedArg(C_MOVING_CURSOR);
    406408    if (pMovingCursor) pMovingCursor->GetArgN(0)->GetBoolValue();
    407     // Next scene sequence.
    408     MHParseNode *pNextScenes = p->GetNamedArg(C_NEXT_SCENES);
    409     if (pNextScenes) { ASSERT(FALSE); } // TODO:
     409    // Next scene sequence: this is just a hint and isn't implemented
    410410}
    411411
    412412void MHScene::PrintMe(FILE *fd, int nTabs) const
     
    559559            m_fIsTagged = TRUE;
    560560            m_nConnectionTag = pCtag->GetIntValue();
    561561        }
    562         else ASSERT(pCtag->m_nNodeType == MHParseNode::PNNull);
    563562    }
    564563    if (p->GetArgCount() > 2) {
    565564        MHParseNode *pTrEff = p->GetArgN(2);
  • libs/libmythfreemheg/Ingredients.h

     
    5555    virtual void Unload(MHEngine *engine) { Destruction(engine); }
    5656
    5757    // Called by the engine to deliver external content.
    58     virtual void ContentArrived(const unsigned char *, int, MHEngine *) { ASSERT(false); }
     58    virtual void ContentArrived(const unsigned char *, int, MHEngine *) { }
    5959
    6060protected:
    6161    bool    m_fInitiallyActive;
  • libs/libmythfreemheg/Programs.cpp

     
    387387        }
    388388        else if (m_Name.Equal("TII")) { // SI_TuneIndexInfo
    389389            // Indicates whether to perform a subsequent TIn quietly or normally.
    390             ASSERT(false);
     390            MHERROR("SI_TuneIndexInfo ResidentProgram is not implemented");
    391391        }
    392392        else if (m_Name.Equal("BSI")) { // SI_GetBasicSI
    393393            // Returns basic SI information about the service indicated by an index
    394394            // returned by GSI.
    395395            // Returns networkID, origNetworkID, transportStreamID, serviceID
    396             ASSERT(false);
     396            MHERROR("SI_GetBasicSI ResidentProgram is not implemented");
    397397        }
    398398        else if (m_Name.Equal("GBI")) { // GetBootInfo
    399399            // Gets the NB_info field.
    400             ASSERT(false);
     400            MHERROR("GetBootInfo ResidentProgram is not implemented");
    401401        }
    402402        else if (m_Name.Equal("CCR")) { // CheckContentRef
    403403            // Sees if an item with a particular content reference is available
    404404            // in the carousel.
    405             ASSERT(false);
     405            MHERROR("CheckContentRef ResidentProgram is not implemented");
    406406        }
    407407        else if (m_Name.Equal("CGR")) { // CheckGroupIDRef
    408408            // Sees if an application or scene with a particular group id
    409409            // is available in the carousel.
    410             ASSERT(false);
     410            MHERROR("CheckGroupIDRef ResidentProgram is not implemented");
    411411        }
    412412        else if (m_Name.Equal("VTG")) { // VideoToGraphics
    413413            // Video to graphics transformation.
    414             ASSERT(false);
     414            MHERROR("VideoToGraphics ResidentProgram is not implemented");
    415415        }
    416416        else if (m_Name.Equal("SWA")) { // SetWidescreenAlignment
    417417            // Sets either LetterBox or Centre-cut-out mode.
    418418            // Seems to be concerned with aligning a 4:3 scene with an underlying 16:9 video
    419             ASSERT(false);
     419            MHERROR("SetWidescreenAlignment ResidentProgram is not implemented");
    420420        }
    421421        else if (m_Name.Equal("GDA")) { // GetDisplayAspectRatio
    422422            // Returns the aspcet ratio.  4:3 => 1, 16:9 => 2
    423             ASSERT(false);
     423            MHERROR("GetDisplayAspectRatio ResidentProgram is not implemented");
    424424        }
    425425        else if (m_Name.Equal("CIS")) { // CI_SendMessage
    426426            // Sends a message to a DVB CI application
    427             ASSERT(false);
     427            MHERROR("CI_SendMessage ResidentProgram is not implemented");
    428428        }
    429429        else if (m_Name.Equal("SSM")) { // SetSubtitleMode
    430430            // Enable or disable subtitles in addition to MHEG.
    431             ASSERT(false);
     431            MHERROR("SetSubtitleMode ResidentProgram is not implemented");
    432432        }
    433433
    434434        else if (m_Name.Equal("WAI")) { // WhoAmI
     
    449449        }
    450450
    451451        else if (m_Name.Equal("DBG")) { // Debug - optional
    452             ASSERT(false);
     452            MHERROR("Debug ResidentProgram is not implemented");
    453453        }
     454
    454455        else {
    455             ASSERT(false);
     456            MHERROR(QString("Unknown ResidentProgram %1").arg(m_Name.Printable()));
    456457        }
    457458    }
    458459    catch (char const *) {
  • libs/libmythfreemheg/Link.cpp

     
    133133    PrintTabs(fd, nTabs);
    134134    fprintf(fd, "{:Link"); MHIngredient::PrintMe(fd, nTabs+1);
    135135    PrintTabs(fd, nTabs+1); fprintf(fd, ":EventSource "); m_EventSource.PrintMe(fd, nTabs+1); fprintf(fd, "\n");
    136     ASSERT(m_nEventType > 0 && m_nEventType <= (int)(sizeof(rchEventType)/sizeof(rchEventType[0])));
     136    MHASSERT(m_nEventType > 0 && m_nEventType <= (int)(sizeof(rchEventType)/sizeof(rchEventType[0])));
    137137    PrintTabs(fd, nTabs+1); fprintf(fd, ":EventType %s\n", rchEventType[m_nEventType-1]);
    138138    // The event data is optional and its format depends on the event type.
    139139    switch (m_EventData.m_Type) {
     
    180180// any event data the link fires whatever the value of the data.
    181181void MHLink::MatchEvent(const MHObjectRef &sourceRefRef, enum EventType ev, const MHUnion &evData, MHEngine *engine)
    182182{
    183     ASSERT(m_fRunning); // Should now be true if we call this.
    184183    if (m_fRunning && m_nEventType == ev && sourceRefRef.Equal(m_EventSource, engine)) { // Source and event type match.
    185184        bool fMatch = false;
    186185        switch (m_EventData.m_Type) {
    187186        case MHUnion::U_None: fMatch = true; break; // No data specified - always matches.
    188         case MHUnion::U_Bool: evData.CheckType(MHUnion::U_Bool);
    189             ASSERT(evData.m_fBoolVal == 0 || evData.m_fBoolVal == 1);
    190             ASSERT(m_EventData.m_fBoolVal == 0 || m_EventData.m_fBoolVal == 1);
    191             fMatch = evData.m_fBoolVal == m_EventData.m_fBoolVal; break;
    192         case MHUnion::U_Int: evData.CheckType(MHUnion::U_Int); fMatch = evData.m_nIntVal == m_EventData.m_nIntVal; break;
    193         case MHUnion::U_String: evData.CheckType(MHUnion::U_String); fMatch = evData.m_StrVal.Equal(m_EventData.m_StrVal); break;
    194         default: ASSERT(false); // Should only be the above types.
     187        case MHUnion::U_Bool:
     188            fMatch = evData.m_Type == MHUnion::U_Bool && evData.m_fBoolVal == m_EventData.m_fBoolVal; break;
     189        case MHUnion::U_Int:
     190            fMatch = evData.m_Type == MHUnion::U_Int && evData.m_nIntVal == m_EventData.m_nIntVal; break;
     191        case MHUnion::U_String:
     192            fMatch = evData.m_Type == MHUnion::U_String && evData.m_StrVal.Equal(m_EventData.m_StrVal); break;
     193        default: fMatch = false; break;
    195194        }
    196195        // Fire the link
    197196        if (fMatch) {
  • libs/libmythfreemheg/Visible.cpp

     
    122122// Return the colour, looking up in the palette if necessary.  Used by the sub-classes
    123123MHRgba MHVisible::GetColour(const MHColour &colour)
    124124{
    125     ASSERT(colour.m_nColIndex < 0); // We don't support palettes.
    126125    int red = 0, green = 0, blue = 0, alpha = 0;
    127126    int cSize = colour.m_ColStr.Size();
    128127    if (cSize != 4) MHLOG(MHLogWarning, QString("Colour string has length %1 not 4.").arg(cSize));
  • libs/libmythtv/mhi.cpp

     
    2727
    2828MHIContext::MHIContext(InteractiveTV *parent)
    2929    : m_parent(parent),     m_dsmcc(NULL),
     30      m_keyProfile(0),
    3031      m_engine(NULL),       m_stop(false),
    3132      m_stopped(false),     m_updated(false),
    3233      m_displayWidth(StdDisplayWidth), m_displayHeight(StdDisplayHeight),
     
    359360        if (m_keyProfile == 4 || m_keyProfile == 5)
    360361            action = 15;
    361362    }
    362     // The EXIT key is supposed to be passed to the MHEG application
    363     // in all circumstances but we need it for
    364363    else if (key == "TEXTEXIT")
    365364        action = 16;
    366365    else if (key == "MENURED")
     
    680679    QRgb qColour = qRgba(colour.red(), colour.green(),
    681680                         colour.blue(), colour.alpha());
    682681
    683     QRgb qTransparent = qRgba(0,0,0,0);
    684 
    685     int  scaledxPos   = xPos * GetWidth()  / MHIContext::StdDisplayWidth;
    686     int  scaledyPos   = yPos * GetHeight() / MHIContext::StdDisplayHeight;
    687     int  xboundary    = scaledxPos & 1;
    688     int  yboundary    = scaledyPos & 1;
    689     int  scaledWidth  = width  * GetWidth()  / MHIContext::StdDisplayWidth;
    690     int  scaledHeight = height * GetHeight() / MHIContext::StdDisplayHeight;
    691 
    692     if (xboundary)
    693     {
    694         scaledxPos--;
    695         scaledWidth++;
    696     }
    697 
    698     if (yboundary)
    699     {
    700         scaledyPos--;
    701         scaledHeight++;
    702     }
    703 
     682    // This is a bit of a mess: we should be able to create a rectangle object.
     683    // Scale the image to the current display size
     684    int scaledWidth = width * GetWidth() / MHIContext::StdDisplayWidth;
     685    int scaledHeight = height * GetHeight() / MHIContext::StdDisplayHeight;
    704686    QImage qImage(scaledWidth, scaledHeight, 32);
    705687    qImage.setAlphaBuffer(true);
    706688
    707     if (xboundary)
     689    // As far as I can tell this is the only way to draw with an
     690    // intermediate transparency.
     691    for (int i = 0; i < scaledHeight; i++)
    708692    {
    709         for (int i = 0; i < scaledHeight; i++)
    710             qImage.setPixel(0, i, qTransparent);
    711     }
    712 
    713     if (yboundary)
    714     {
    715693        for (int j = 0; j < scaledWidth; j++)
    716             qImage.setPixel(j, 0, qTransparent);
     694        {
     695            qImage.setPixel(j, i, qColour);
     696        }
    717697    }
    718698
    719     // As far as I can tell this is the only way to draw
    720     // with an intermediate transparency. -- david mathews
    721     for (int i = yboundary; i < scaledHeight; i++)
    722         for (int j = xboundary; j < scaledWidth; j++)
    723             qImage.setPixel(j, i, qColour);
    724 
    725     AddToDisplay(qImage, scaledxPos, scaledyPos);
     699    AddToDisplay(qImage,
     700        xPos * GetWidth() / MHIContext::StdDisplayWidth,
     701        yPos * GetHeight() / MHIContext::StdDisplayHeight);
    726702}
    727703
    728704// Draw an image at the specified position.
     
    916892    // X positions are computed to 64ths and rounded.
    917893    // Y positions are in pixels
    918894    int posX = x << 6;
    919     // Add in the (negative) descender rounded up
    920     int pixelY = y + ((face->descender - ((1<<6) -1)) >> 6);
     895    int pixelY = y;
    921896    FT_Bool useKerning = FT_HAS_KERNING(face);
    922897    FT_UInt previous = 0;
    923898